Last active
October 13, 2017 08:49
-
-
Save r4fx/af42d649f7c1b5e2b786 to your computer and use it in GitHub Desktop.
check if plugin is ready
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
// 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