zurb / twentytwenty

jQuery Plugin to Compare Images
ISC License
1.27k stars 295 forks source link

destroy / reinit / events / hem zone #97

Open cf-git opened 6 years ago

cf-git commented 6 years ago

Hello. Thank you. You done great work.

  1. I'm interesing how i can how i can destroy or reinit your lib.
    • I'm try destroy container with trigger on container
      
      container.on('destroy.twentytwenty',` function() {
      var $this = $(this);
      beforeImg.css('clip', "");
      afterImg.css('clip', "");
      $this.find('.twentytwenty-overlay').remove();
      $this.find('.twentytwenty-handle').remove();
      $this.find('img')
          .removeClass('twentytwenty-before')
          .removeClass('twentytwenty-after')
          .each(function () {
            this.style.removeProperty('clip');
        });
      $this.unwrap('.twentytwenty-wrapper');
      $this.off('touchmove.twentytwenty')
          .off('mousedown.twentytwenty')
          .off('mouseleave.twentytwenty')
          .off('mousemove.twentytwenty')
          .off("movestart.twentytwenty")
          .off("move.twentytwenty")
          .off("moveend.twentytwenty");
      });
$this.trigger('destroy');

For this i will add namespace for events which use container. 
Then i have problems with clip. I can't remove clip from images.

2. How can i add some reinit method (or function or event)
 - Sometimes i need refresh content on page dinamicaly and possible no need destroy container to renew content

3. I think there need custom events 
 - There, possible, need for events chaining and simplify implementation in/with other code or libraries.

4. I think possible need implement hem zones but this if from custom events section
 - I mean after and before mouseover zones, to call some events or setted callback function

Thank you!