-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8beaca6
commit fd26f14
Showing
6 changed files
with
152 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
// Add imports above this line | ||
import { galleryItems } from './gallery-items'; | ||
// Change code below this line | ||
|
||
console.log(galleryItems); | ||
import SimpleLightbox from 'simplelightbox'; | ||
|
||
import 'simplelightbox/dist/simple-lightbox.min.css'; | ||
|
||
const galleryBox = document.querySelector('.gallery'); | ||
|
||
const markup = galleryItems.map( | ||
({ preview, original, description }) => `<li class="gallery__item"> | ||
<a class="gallery__link" href="${original}"> | ||
<img class="gallery__image" src="${preview}" alt="${description}" /> | ||
</a> | ||
</li>` | ||
); | ||
galleryBox.insertAdjacentHTML('beforeend', markup.join('')); | ||
|
||
const lightbox = new SimpleLightbox('.gallery a', { | ||
captionsData: 'alt', | ||
captionDelay: 250, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
import Player from '@vimeo/player'; | ||
|
||
import throttle from 'lodash.throttle'; | ||
|
||
const iframe = document.getElementById('vimeo-player'); | ||
const player = new Player(iframe);// создаем функцию прототипом которой есть ф-я Плеер | ||
|
||
player.on( | ||
'timeupdate', | ||
throttle(a => { | ||
localStorage.setItem('videoplayer-current-time', a.seconds); | ||
}, 1000) | ||
); | ||
|
||
let currentTime = localStorage.getItem('videoplayer-current-time'); | ||
|
||
player | ||
.setCurrentTime(currentTime) | ||
.then(function (seconds) {}) | ||
.catch(function (error) { | ||
switch (error.name) { | ||
case 'RangeError': | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,37 @@ | ||
import throttle from 'lodash.throttle'; | ||
|
||
//1.refs | ||
const formEl = document.querySelector('.feedback-form'); | ||
const inputEl = document.querySelector('input[name="email"]'); | ||
const messageEl = document.querySelector('textarea[name="message"]'); | ||
|
||
|
||
formEl.addEventListener('input', throttle(onInput, 500)); | ||
|
||
function onInput() { | ||
const storageObject = { email: inputEl.value, message: messageEl.value }; | ||
|
||
localStorage.setItem('feedback-form-state', JSON.stringify(storageObject)); | ||
} | ||
|
||
formEl.addEventListener('submit', evt => { | ||
evt.preventDefault(); | ||
console.log(JSON.parse(localStorage.getItem('feedback-form-state'))); | ||
localStorage.clear(); | ||
evt.target.reset(); | ||
}); | ||
|
||
const load = key => { | ||
try { | ||
const serializedState = localStorage.getItem(key); | ||
return serializedState === null ? undefined : JSON.parse(serializedState); | ||
} catch (error) { | ||
console.error('Get state error: ', error.message); | ||
} | ||
}; | ||
|
||
const storageData = load('feedback-form-state'); | ||
if (storageData) { | ||
inputEl.value = storageData.email; | ||
messageEl.value = storageData.message; | ||
} |