src/materialize/materialize.js
function returnToOriginal() {

        doneAnimating = false;

        var placeholder = origin.parent('.material-placeholder');
        var windowWidth = window.innerWidth;
        var windowHeight = window.innerHeight;
        var originalWidth = origin.data('width');
        var originalHeight = origin.data('height');

        origin.velocity("stop", true);
        $('#materialbox-overlay').velocity("stop", true);
        $('.materialbox-caption').velocity("stop", true);


        $('#materialbox-overlay').velocity({opacity: 0}, {
          duration: outDuration, // Delay prevents animation overlapping
          queue: false, easing: 'easeOutQuad',
          complete: function(){
            // Remove Overlay
            overlayActive = false;
            $(this).remove();
          }
        });

        // Resize Image
        origin.velocity(
          {
            width: originalWidth,
            height: originalHeight,
            left: 0,
            top: 0
          },
          {
            duration: outDuration,
            queue: false, easing: 'easeOutQuad',
            complete: function() {
              placeholder.css({
                height: '',
                width: '',
                position: '',
                top: '',
                left: ''
              });

              origin.removeAttr('style');
              origin.attr('style', originInlineStyles);

              // Remove class
              origin.removeClass('active');
              doneAnimating = true;

              // Remove overflow overrides on ancestors
              if (ancestorsChanged) {
                ancestorsChanged.css('overflow', '');
              }
            }
          }
        );

        // Remove Caption + reset css settings on image
        $('.materialbox-caption').velocity({opacity: 0}, {
          duration: outDuration, // Delay prevents animation overlapping
          queue: false, easing: 'easeOutQuad',
          complete: function(){
            $(this).remove();
          }
        });

      }
function returnToOriginal() {

        doneAnimating = false;

        var placeholder = origin.parent('.material-placeholder');
        var windowWidth = window.innerWidth;
        var windowHeight = window.innerHeight;
        var originalWidth = origin.data('width');
        var originalHeight = origin.data('height');

        origin.velocity("stop", true);
        $('#materialbox-overlay').velocity("stop", true);
        $('.materialbox-caption').velocity("stop", true);


        $('#materialbox-overlay').velocity({opacity: 0}, {
          duration: outDuration, // Delay prevents animation overlapping
          queue: false, easing: 'easeOutQuad',
          complete: function(){
            // Remove Overlay
            overlayActive = false;
            $(this).remove();
          }
        });

        // Resize Image
        origin.velocity(
          {
            width: originalWidth,
            height: originalHeight,
            left: 0,
            top: 0
          },
          {
            duration: outDuration,
            queue: false, easing: 'easeOutQuad',
            complete: function() {
              placeholder.css({
                height: '',
                width: '',
                position: '',
                top: '',
                left: ''
              });

              origin.removeAttr('style');
              origin.attr('style', originInlineStyles);

              // Remove class
              origin.removeClass('active');
              doneAnimating = true;

              // Remove overflow overrides on ancestors
              if (ancestorsChanged) {
                ancestorsChanged.css('overflow', '');
              }
            }
          }
        );

        // Remove Caption + reset css settings on image
        $('.materialbox-caption').velocity({opacity: 0}, {
          duration: outDuration, // Delay prevents animation overlapping
          queue: false, easing: 'easeOutQuad',
          complete: function(){
            $(this).remove();
          }
        });

      }
function returnToOriginal ( ) { doneAnimating = false ; var placeholder = origin . parent ( '.material-placeholder' ) ; var windowWidth = window . innerWidth ; var windowHeight = window . innerHeight ; var originalWidth = origin . data ( 'width' ) ; var originalHeight = origin . data ( 'height' ) ; origin . velocity ( "stop" , true ) ; $ ( '#materialbox-overlay' ) . velocity ( "stop" , true ) ; $ ( '.materialbox-caption' ) . velocity ( "stop" , true ) ; $ ( '#materialbox-overlay' ) . velocity ( { opacity : 0 } , { duration : outDuration , // Delay prevents animation overlapping queue : false , easing : 'easeOutQuad' , complete : function ( ) { // Remove Overlay overlayActive = false ; $ ( this ) . remove ( ) ; } } ) ; // Resize Image origin . velocity ( { width : originalWidth , height : originalHeight , left : 0 , top : 0 } , { duration : outDuration , queue : false , easing : 'easeOutQuad' , complete : function ( ) { placeholder . css ( { height : '' , width : '' , position : '' , top : '' , left : '' } ) ; origin . removeAttr ( 'style' ) ; origin . attr ( 'style' , originInlineStyles ) ; // Remove class origin . removeClass ( 'active' ) ; doneAnimating = true ; // Remove overflow overrides on ancestors if ( ancestorsChanged ) { ancestorsChanged . css ( 'overflow' , '' ) ; } } } ) ; // Remove Caption + reset css settings on image $ ( '.materialbox-caption' ) . velocity ( { opacity : 0 } , { duration : outDuration , // Delay prevents animation overlapping queue : false , easing : 'easeOutQuad' , complete : function ( ) { $ ( this ) . remove ( ) ; } } ) ; }
This function returns the modaled image to the original spot
This function returns the modaled image to the original spot