Arkadaşlar bir sayfanın içinde iki adet jquery çalıştırmaya çalışıyorum ama olmuyor yardımcı olabilcek arkadaş var mı kodlar :
jQuery(document).ready(function($){
var modalTriggerBts = $('a[data-type="cd-modal-trigger"]'),
coverLayer = $('.cd-cover-layer');
var duration = 600,
epsilon = (1000 / 60 / duration) / 4,
firstCustomMinaAnimation = bezier(.63,.35,.48,.92, epsilon);
modalTriggerBts.each(function(){
initModal($(this));
});
function initModal(modalTrigger) {
var modalTriggerId = modalTrigger.attr('id'),
modal = $('.cd-modal[data-modal="'+ modalTriggerId +'"]'),
svgCoverLayer = modal.children('.cd-svg-bg'),
paths = svgCoverLayer.find('path'),
pathsArray = [];
pathsArray[0] = Snap('#'+paths.eq(0).attr('id')),
pathsArray[1] = Snap('#'+paths.eq(1).attr('id')),
pathsArray[2] = Snap('#'+paths.eq(2).attr('id'));
var pathSteps = [];
pathSteps[0] = svgCoverLayer.data('step1');
pathSteps[1] = svgCoverLayer.data('step2');
pathSteps[2] = svgCoverLayer.data('step3');
pathSteps[3] = svgCoverLayer.data('step4');
pathSteps[4] = svgCoverLayer.data('step5');
pathSteps[5] = svgCoverLayer.data('step6');
modalTrigger.on('click', function(event){
event.preventDefault();
modal.addClass('modal-is-visible');
coverLayer.addClass('modal-is-visible');
animateModal(pathsArray, pathSteps, duration, 'open');
});
modal.on('click', '.modal-close', function(event){
event.preventDefault();
modal.removeClass('modal-is-visible');
coverLayer.removeClass('modal-is-visible');
animateModal(pathsArray, pathSteps, duration, 'close');
});
}
function animateModal(paths, pathSteps, duration, animationType) {
var path1 = ( animationType == 'open' ) ? pathSteps[1] : pathSteps[0],
path2 = ( animationType == 'open' ) ? pathSteps[3] : pathSteps[2],
path3 = ( animationType == 'open' ) ? pathSteps[5] : pathSteps[4];
paths[0].animate({'d': path1}, duration, firstCustomMinaAnimation);
paths[1].animate({'d': path2}, duration, firstCustomMinaAnimation);
paths[2].animate({'d': path3}, duration, firstCustomMinaAnimation);
}
function bezier(x1, y1, x2, y2, epsilon){
var curveX = function(t){
var v = 1 - t;
return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t;
};
var curveY = function(t){
var v = 1 - t;
return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t;
};
var derivativeCurveX = function(t){
var v = 1 - t;
return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (- t * t * t + 2 * v * t) * x2;
};
return function(t){
var x = t, t0, t1, t2, x2, d2, i;
for (t2 = x, i = 0; i < 8; i++){
x2 = curveX(t2) - x;
if (Math.abs(x2) < epsilon) return curveY(t2);
d2 = derivativeCurveX(t2);
if (Math.abs(d2) < 1e-6) break;
t2 = t2 - x2 / d2;
}
t0 = 0, t1 = 1, t2 = x;
if (t2 < t0) return curveY(t0);
if (t2 > t1) return curveY(t1);
while (t0 < t1){
x2 = curveX(t2);
if (Math.abs(x2 - x) < epsilon) return curveY(t2);
if (x > x2) t0 = t2;
else t1 = t2;
t2 = (t1 - t0) * .5 + t0;
}
return curveY(t2);
};
};
});KOD 2 :
jQuery(document).ready(function() {
articlesWrapper = $('.cd-articles');
if( articlesWrapper.length > 0 ) {
var windowHeight = $(window).height(),
articles = articlesWrapper.find('article'),
aside = $('.cd-read-more'),
articleSidebarLinks = aside.find('li');
var scrolling = false,
sidebarAnimation = false,
resizing = false,
mq = checkMQ(),
svgCircleLength = parseInt(Math.PI*(articleSidebarLinks.eq(0).find('circle').attr('r')*2));
if( mq == 'desktop' ) {
$(window).on('scroll', checkRead);
$(window).on('scroll', checkSidebar);
}
$(window).on('resize', resetScroll);
updateArticle();
updateSidebarPosition();
aside.on('click', 'a', function(event){
event.preventDefault();
var selectedArticle = articles.eq($(this).parent('li').index()),
selectedArticleTop = selectedArticle.offset().top;
$(window).off('scroll', checkRead);
$('body,html').animate(
{'scrollTop': selectedArticleTop + 2},
300, function(){
checkRead();
$(window).on('scroll', checkRead);
}
);
});
}
function checkRead() {
if( !scrolling ) {
scrolling = true;
(!window.requestAnimationFrame) ? setTimeout(updateArticle, 300) : window.requestAnimationFrame(updateArticle);
}
}
function checkSidebar() {
if( !sidebarAnimation ) {
sidebarAnimation = true;
(!window.requestAnimationFrame) ? setTimeout(updateSidebarPosition, 300) : window.requestAnimationFrame(updateSidebarPosition);
}
}
function resetScroll() {
if( !resizing ) {
resizing = true;
(!window.requestAnimationFrame) ? setTimeout(updateParams, 300) : window.requestAnimationFrame(updateParams);
}
}
function updateParams() {
windowHeight = $(window).height();
mq = checkMQ();
$(window).off('scroll', checkRead);
$(window).off('scroll', checkSidebar);
if( mq == 'desktop') {
$(window).on('scroll', checkRead);
$(window).on('scroll', checkSidebar);
}
resizing = false;
}
function updateArticle() {
var scrollTop = $(window).scrollTop();
articles.each(function(){
var article = $(this),
articleTop = article.offset().top,
articleHeight = article.outerHeight(),
articleSidebarLink = articleSidebarLinks.eq(article.index()).children('a');
if( article.is(':last-of-type') ) articleHeight = articleHeight - windowHeight;
if( articleTop > scrollTop) {
articleSidebarLink.removeClass('read reading');
} else if( scrollTop >= articleTop && articleTop + articleHeight > scrollTop) {
var dashoffsetValue = svgCircleLength*( 1 - (scrollTop - articleTop)/articleHeight);
articleSidebarLink.addClass('reading').removeClass('read').find('circle').attr({ 'stroke-dashoffset': dashoffsetValue });
changeUrl(articleSidebarLink.attr('href'));
} else {
articleSidebarLink.removeClass('reading').addClass('read');
}
});
scrolling = false;
}
function updateSidebarPosition() {
var articlesWrapperTop = articlesWrapper.offset().top,
articlesWrapperHeight = articlesWrapper.outerHeight(),
scrollTop = $(window).scrollTop();
if( scrollTop < articlesWrapperTop) {
aside.removeClass('fixed').attr('style', '');
} else if( scrollTop >= articlesWrapperTop && scrollTop < articlesWrapperTop + articlesWrapperHeight - windowHeight) {
aside.addClass('fixed').attr('style', '');
} else {
var articlePaddingTop = Number(articles.eq(1).css('padding-top').replace('px', ''));
if( aside.hasClass('fixed') ) aside.removeClass('fixed').css('top', articlesWrapperHeight + articlePaddingTop - windowHeight + 'px');
}
sidebarAnimation = false;
}
function changeUrl(link) {
var pageArray = location.pathname.split('/'),
actualPage = pageArray[pageArray.length - 1] ;
if( actualPage != link && history.pushState ) window.history.pushState({path: link},'',link);
}
function checkMQ() {
return window.getComputedStyle(articlesWrapper.get(0), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "");
}
});