Answer the question
In order to leave comments, you need to log in
Why is the function from the imported library not visible?
I connect the library for filtering elements Isotope .
For some reason, the built-in matchesSelector function is not visible below in the code.
Although in the demos everything works . I used this library before, but did not connect it with a requier, and everything worked.
The code:
const Isotope = require('isotope-layout');
const destinations = new Isotope('.destination-grid', {
itemSelector: '.destination-grid-element',
layoutMode: 'fitRows'
});
const destinationFiltersActive = 'destination-controls__filter-button_active';
const destinationFilters = document.querySelector('.destination-controls');
destinationFilters.addEventListener('click', (event) => {
if(!matchesSelector(event.target, 'button')){
return console.log('not matches');
}
const filterValue = event.target.getAttribute('data-filter');
destinations.arrange({filter: filterValue});
});
const radioButtonGroup = (buttonGroup) => {
buttonGroup.addEventListener('click', (event) => {
if (!matchesSelector(event.target, 'button')) {
return console.log('not matches');
}
buttonGroup.classList.toggle(destinationFiltersActive);
event.target.classList.add(destinationFiltersActive);
});
};
const buttonGroups = document.querySelectorAll('.destination-controls__filter-button');
for (let i = 0, len = buttonGroups.length; i < len; i++ ) {
let buttonGroup = buttonGroups[i];
radioButtonGroup(buttonGroup);
};
gulp.task('js', () => {
browserify('./src/js/main.js')
.transform(babelify)
.bundle()
.pipe(source('all.js'))
.pipe(gulp.dest('./dist/scripts'))
.pipe(connect.reload())
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question