`) imageFullscreen.lastPrepended = $('img.orig_image'); var foundOrig = false; $.each(parentShowImagesFor.find('[data-src]'), function (i, el) { if (eventTarget == el) { foundOrig = true; } if (!foundOrig) { if ($(el).attr('data-src').indexOf(imageFullscreen.sourceImage.replace('.jpg', '')) == -1) { if (imageFullscreen.prependImages.findIndex(function(elem){ if($(elem).attr('data-src').indexOf($(el).attr('data-src').replace('.jpg', '')) > -1){ return true } }) == -1 ){ imageFullscreen.prependImages.push(el); } } } else { if ($(el).attr('data-src').indexOf(imageFullscreen.sourceImage.replace('.jpg', '')) == -1) { if (imageFullscreen.appendImages.findIndex(function(elem){ if($(elem).attr('data-src').indexOf($(el).attr('data-src').replace('.jpg', '')) > -1){ return true } }) == -1){ imageFullscreen.appendImages.push(el); } } } }); var scrollToInterval = setInterval(function () { if ($('img.orig_image').length > 0 && $('img.orig_image').height() > 0) { $('img.orig_image').css('margin-top', '0px'); clearInterval(scrollToInterval) $('.image_large_preview_body').css('margin-top', '20px'); $("#img_large_modal").scrollTop(20); } }, 100); // imageFullscreen.initLargeImagePreviewDraggable(); imageFullscreen.initScrollAndArrows(); imageFullscreen.apPend(); }, windowMouseBind : function (event) { event.stopImmediatePropagation() if (event.originalEvent.wheelDelta >= 0 && $('#img_large_modal').hasClass('show')) { if (imageFullscreen.lastPrepended) { if ($(imageFullscreen.lastPrepended).css('margin-top')) { if ($(imageFullscreen.lastPrepended).css('margin-top').split('px').join('') < 0) { // $(imageFullscreen.lastPrepended).parent('div').css('height', 'unset'); $(imageFullscreen.lastPrepended).css('margin-top', (Number($(imageFullscreen.lastPrepended).css('margin-top').split('px').join('')) + event.originalEvent.wheelDelta/2) + 'px'); return } } $(imageFullscreen.lastPrepended).css('margin-top', '0px'); imageFullscreen.prePend() } } else { imageFullscreen.apPend(); } return true; }, windowTouchBind : function (event) { event.stopImmediatePropagation() if (touchDelta < -100 && $('#img_large_modal').hasClass('show')) { clearTimeout(touchPrepend) touchPrepend = setTimeout(function(){imageFullscreen.prePend(true)},500); } else { clearTimeout(touchAppend) touchAppend = setTimeout(function(){imageFullscreen.apPend();},500); } return true; }, expandImage2: function (direction="wide") { event.stopImmediatePropagation() currentEl = -1; currentDeltaTop = 99999; $.each($('.img_modal_div'), function (idx, el) { let calcTop = $(el).offset().top let calcBottom = Math.abs($(el).offset().top + $(el).height())- $(window).height(); let calc = calcTop - calcBottom if (calc < currentDelta) { currentDelta = calc currentEl = el; currentIDX = idx } }); if (direction == "wide") { $(currentEl).find('img').css('width', '100vw') $(currentEl).find('img').css('height', 'auto') $(currentEl).find('img').css('max-height', 'unset') $(currentEl).find('img').css('max-width', '100vw') }else{ $(currentEl).find('img').css('width', 'auto') $(currentEl).find('img').css('height', '100vh') $(currentEl).find('img').css('max-height', '100vh') $(currentEl).find('img').css('max-width', 'unset') } }, expandImage: function (direction="wide") { // $('.img_modal_div').removeClass('scroll-to-me') // console.log(event.target) // console.log($(event.target)) // console.log(event) var total = 0; var currentEl = -1; var found = false; if ($(event.target).hasClass('img_modal_div')){ currentEl = event.target; }else{ currentEl = $(event.target).parent('.img_modal_div')[0] } $(currentEl).addClass('scroll-to-me'); // event.stopImmediatePropagation() // console.log("currentEl") // console.log(currentEl) if (false) { $.each($('.img_modal_div'), function (idx, el) { if (!found) { total += $(el).height(); var calc = total - $(window).height() / 2; // console.log($("#img_large_modal").scrollTop() - calc, total, $(el), idx) if ($("#img_large_modal").scrollTop() - calc < 0) { found = true currentEl = el; } } }); } // $('.preview_image_modal').hide() if ($($('.preview_image_modal')[0]).hasClass('preview_image_modal_wide')){ $('.img_modal_div').css('overflow','hidden') $('.preview_image_modal').removeClass('preview_image_modal_wide') currentPreviewClass = "" }else{ $('.img_modal_div').css('overflow','scroll') $('.preview_image_modal').removeClass('preview_image_modal_wide') $('.preview_image_modal').addClass('preview_image_modal_wide') currentPreviewClass = "preview_image_modal_wide" } // setTimeout(function(){ var found = false; var scrollTop= 0; $.each($('.img_modal_div'), function (idx, el) { if (!found) { if ($(el).hasClass('scroll-to-me')) { found = true // scrollTop +=20; }else { scrollTop += $(el).height()+10; } } }); // console.log($("#img_large_modal").scrollTop(), scrollTop); $("#img_large_modal").scrollTop(scrollTop) // $('.preview_image_modal').show() $('.img_modal_div').removeClass('scroll-to-me') // }, 2000, currentEl) // $(currentEl).find('img.preview_image_modal').css('margin-top', '0px'); return if (direction == "wide") { $(currentEl).find('img').css('width', '100vw') $(currentEl).find('img').css('height', 'auto') $(currentEl).find('img').css('max-height', 'unset') $(currentEl).find('img').css('max-width', '100vw') }else{ $(currentEl).find('img').css('width', 'auto') $(currentEl).find('img').css('height', '100vh') $(currentEl).find('img').css('max-height', '100vh') $(currentEl).find('img').css('max-width', 'unset') } setTimeout(function(){ $("#img_large_modal").scrollTop(scrollTop + 10) }, 10, scrollTop) }, windowArrowBind : function (e) { e.stopImmediatePropagation() var arrow = {left: 37, up: 38, right: 39, down: 40}; if ($('.modal1:hover').length == 0){ return } if ($('#img_large_modal').is(':visible')) { // console.log("key!", e.which) switch (e.which) { case 27: $('#img_large_modal').removeClass('show'); imageFullscreen.unfixBody(); break; case arrow.left: e.stopPropagation() e.preventDefault() imageFullscreen.prePend(true); //$("#img_large_modal").scrollTop(0); break; case arrow.up: e.stopPropagation() e.preventDefault() imageFullscreen.prePend(true); //$("#img_large_modal").scrollTop(0); break; case arrow.right: e.stopPropagation() e.preventDefault() var aaa = imageFullscreen.apPend(); break; case arrow.down: e.stopPropagation() e.preventDefault() var sss = imageFullscreen.apPend(); break; } currentDelta = 99999; currentEl = -1; currentIDX = -1; $.each($('.img_modal_div'), function (idx, el) { if (Math.abs($(el).offset().top - $("#img_large_modal").offset().top) < currentDelta) { currentDelta = Math.abs($(el).offset().top - $("#img_large_modal").offset().top) currentEl = el; currentIDX = idx; } }); if (currentIDX == 0) { prevEl = $('.img_modal_div')[currentIDX]; } else { prevEl = $('.img_modal_div')[currentIDX - 1]; } if (currentIDX == $('.img_modal_div').length - 1) { nextEl = $('.img_modal_div')[currentIDX]; } else { nextEl = $('.img_modal_div')[currentIDX + 1]; } switch (e.which) { case arrow.left: $(prevEl).find('img').css('margin-top', '0px'); $("#img_large_modal").scrollTop(($(prevEl).offset().top + $("#img_large_modal").scrollTop())-window.scrollY) break; case arrow.up: $(prevEl).find('img').css('margin-top', '0px'); $("#img_large_modal").scrollTop(($(prevEl).offset().top + $("#img_large_modal").scrollTop())-window.scrollY) break; case arrow.right: $("#img_large_modal").scrollTop(($(nextEl).offset().top + $("#img_large_modal").scrollTop())-window.scrollY) break; case arrow.down: $("#img_large_modal").scrollTop(($(nextEl).offset().top + $("#img_large_modal").scrollTop())-window.scrollY) break; } } return true; }, initScrollAndArrows: function () { $(window).bind('mousewheel', imageFullscreen.windowMouseBind); $(window).bind('touchend', imageFullscreen.windowTouchBind); $(window).bind('keydown', imageFullscreen.windowArrowBind) }, initLargeImagePreviewDraggable: function () { $(".img_modal_div").draggable({ helper: "clone", cursor: "grabbing", scroll: false, appendTo: "body", zIndex: 1200, cursorAt: {left: 50, top: 50}, drag: function (event, ui) { ui.position.top = event.pageY - 75; ui.position.left = event.pageX - 75; }, start: function (event, ui) { $(ui.helper).children('img').css('width', '100px'); $(ui.helper).css('width', '100px'); $(ui.helper).css('margin', '0px'); comment_div.show() } }); }, clearIntervals: function () { for (var i in imageFullscreen.intervals) { clearInterval(imageFullscreen.intervals[i]) } imageFullscreen.intervals = []; }, prePend: function (arrow = false) { if (imageFullscreen.prependImages.length > 0) { pRand = String(Math.floor(Math.random() * 100000)); var prependThis = $(imageFullscreen.prependImages.pop()) if (arrow) { $('.modal-body').prepend('
`) } else { $('.modal-body').prepend('
`) imageFullscreen.lastPrepended = $('.' + pRand); imageFullscreen.intervals.push(setInterval(function () { if ($(imageFullscreen.lastPrepended).height() > 10) { if (imageFullscreen.prependImages.length == 0) { $(imageFullscreen.lastPrepended).css('margin-top', -1 * $(imageFullscreen.lastPrepended).height() + 'px'); $('.image_large_preview_body').css('margin-top', '0px'); } else { $(imageFullscreen.lastPrepended).css('margin-top', -1 * $(imageFullscreen.lastPrepended).height() + 10 + 'px'); $('.image_large_preview_body').css('margin-top', '20px'); } imageFullscreen.clearIntervals() } }, 10)); } // imageFullscreen.initLargeImagePreviewDraggable(); } }, apPend: function () { if (imageFullscreen.appendImages.length > 0) { if (imageFullscreen.appendImages.length != 1) { var appendThis = $(imageFullscreen.appendImages.shift()) $('.modal-body').append('
`) } else { var appendThis = $(imageFullscreen.appendImages.shift()) $('.modal-body').append('
`) imageFullscreen.intervals.push(setInterval(function () { if ($('img.last_append').height() > 10) { $('img.last_append').css('margin-bottom', 'calc(100vh - ' + $('img.last_append').height() + 'px)'); imageFullscreen.clearIntervals() } }, 10)) // imageFullscreen.initLargeImagePreviewDraggable(); } } return true } } var ts; var touchDelta; $(document).bind('touchstart', function (e){ ts = e.originalEvent.touches[0].clientY; }); $(document).bind('touchend', function (e){ var te = e.originalEvent.changedTouches[0].clientY; touchDelta = ts - te; });
Licensing Agreement | Terms of Service | Privacy Policy | EULA
© 2024 Daz Productions Inc. All Rights Reserved.