Skip to content

Instantly share code, notes, and snippets.

@r4fx
Last active October 13, 2017 08:49
Show Gist options
  • Save r4fx/af42d649f7c1b5e2b786 to your computer and use it in GitHub Desktop.
Save r4fx/af42d649f7c1b5e2b786 to your computer and use it in GitHub Desktop.
check if plugin is ready
// Check if plugin is ready to call
function checkVendor(vendor, selector, options) {
if (!jQuery()[vendor]) {
console.log('ERROR: obsadź plugin: ' + vendor);
} else {
$(selector)[vendor](options);
}
}
// Example use
checkVendor('select2', nativeSelect, defaultOptions);
// or the fastest way
if ($.fn.magnificPopup) {
$('.popup').magnificPopup({
type: 'image',
closeOnContentClick: true,
closeBtnInside: true
});
}
// vanilla js
if (typeof Swiper === "function") {
var swiper = new Swiper('.swiper-container', {
paginationClickable: true,
pagination: '.swiper-pagination',
autoplay: 5000,
loop: true,
threshold: 100,
spaceBetween: 15,
effect: 'slide',
speed: 700
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment