javascript - How to create a slideshow with drag drop clones -
i want create page user can choose images shown in slideshow. attempting use mootools drag , drop , use lightgallery.js.
how can pass array of dropped images dynamicel? there way load images using id/class of #cart.item?
any appreciated. , apologies in advance being new @ coding.
here codepen seems working http://codepen.io/ssab/pen/qgykvo
$(function() { jquery('#dynamic').on('click', function() { var selected_image = []; jquery( "#cart.item img" ).each(function() { var item1 = { src: $(this).find('img').attr('src'), thumb: $(this).find('img').attr('data-thumb'), subhtml: '<h4></h4>' }; selected_image.push(item1); }); jquery(this).lightgallery({ dynamic: true, dynamicel: selected_image }) }); }); var drop = $('cart'); var dropfx = drop.effect('background-color', {wait: false}); // wait needed toggle effect, $$('.item').each(function(item){ item.addevent('mousedown', function(e) { e = new event(e).stop(); var clone = this.clone() .setstyles(this.getcoordinates()) // returns object left/top/bottom/right, perfect .setstyles({'opacity': 0.7, 'position': 'absolute'}) .addevent('emptydrop', function() { this.remove(); drop.removeevents(); }).inject(document.body); drop.addevents({ 'drop': function() { drop.removeevents(); clone.remove(); item.clone().inject(drop); dropfx.start('7389ae').chain(dropfx.start.pass('ffffff', dropfx)); }, 'over': function() { dropfx.start('98b5c1'); }, 'leave': function() { dropfx.start('ffffff'); } }); var drag = clone.makedraggable({ droppables: [drop] }); // returns dragged element drag.start(e); // start event manual }); });
you can launch light box in 2 ways.
- when dropping item can populate array
dynamicel, or - when dynamic button clicked create array of elements.
here option 2 implemented: http://codepen.io/imranweb7/pen/zorrlg?editors=1111 logic behind implementations per html copied dropped area.
please let me know explanations.
Comments
Post a Comment