Skip to content

Commit

Permalink
#1commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgiySergeev committed Jul 21, 2023
1 parent 8beaca6 commit fd26f14
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 5 deletions.
66 changes: 65 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"url": "https://github.com/goitacademy/parcel-project-template/issues"
},
"dependencies": {
"modern-normalize": "^1.1.0"
"@vimeo/player": "^2.20.1",
"lodash.throttle": "^4.1.1",
"modern-normalize": "^1.1.0",
"simplelightbox": "^2.14.1"
},
"devDependencies": {
"@parcel/transformer-sass": "^2.6.0",
Expand Down
1 change: 1 addition & 0 deletions src/css/01-gallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}

.gallery__item {
list-style: none;
position: relative;
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.2),
0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 2px 1px -1px rgba(0, 0, 0, 0.12);
Expand Down
22 changes: 19 additions & 3 deletions src/js/01-gallery.js
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,
});
27 changes: 27 additions & 0 deletions src/js/02-video.js
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;
}
});
36 changes: 36 additions & 0 deletions src/js/03-feedback.js
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;
}

0 comments on commit fd26f14

Please sign in to comment.