Team:UNITN-Trento/JS/Library/jmslideshow

From 2013.igem.org

Revision as of 09:10, 25 June 2013 by Ggirelli (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

/*!

* jquery.scrollto.js 0.0.1 - https://github.com/yckart/jquery.scrollto.js
* Scroll smooth to any element in your DOM.
*
* Copyright (c) 2012 Yannick Albert (http://yckart.com)
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php).
* 2013/02/17
**/

$.scrollTo = $.fn.scrollTo = function(x, y, options){

   if (!(this instanceof $)) return $.fn.scrollTo.apply($('html, body'), arguments);
   options = $.extend({}, {
       gap: {
           x: 0,
           y: 0
       },
       animation: {
           easing: 'swing',
           duration: 600,
           complete: $.noop,
           step: $.noop
       }
   }, options);
   return this.each(function(){
       var elem = $(this);
       elem.stop().animate({
           scrollLeft: !isNaN(Number(x)) ? x : $(y).offset().left + options.gap.x,
           scrollTop: !isNaN(Number(y)) ? y : $(y).offset().top + options.gap.y
       }, options.animation);
   });

};

/**

* onHashChange (oHch) event handler
* @version onHashChange 1.0
* @copyright Copyright (c) 2010-2012, Gabriele Girelli
* @author ggirelli <g.girelli@studenti.unitn.it>
*/

function oHch(event) {

   var getHashValue = function() {
       var hasValue = window.location.hash.split("#")[1];
       if (typeof hasValue == "undefined") {
           return false;
       }
       return hasValue;
   }

var lastHash = getHashValue();

   (function listenHash() {
       var hash = getHashValue();
       if (hash !== lastHash) {
           event();
           lastHash = hash;
       }
       var t = setTimeout(listenHash, 100);
   })();

}

/**

* onTimeChange (oTch) event handler
* @version onTimeChange 1.0
* @copyright Copyright (c) 2010-2012, Gabriele Girelli
* @author ggirelli <g.girelli@studenti.unitn.it>
*/

function oTch(event) {

   var getTimeValue = function() {
       var d = new Date();
       return d.getTime();
   }
       var lastTime = getTimeValue();
   (function listenTime() {
       var time = getTimeValue();
       if (time !== lastTime) {
           event();
           lastTime = time;
       }
       var t = setTimeout(listenTime, 100);
   })();

}

/**

* onWidthChange (oWri) event handler
* @version onWidthChange 1.0
* @copyright Copyright (c) 2010-2012, Gabriele Girelli
* @author ggirelli <g.girelli@studenti.unitn.it>
*/

function oWch(event) {

   var getWidthValue = function() {
       return window.innerWidth;
   }
       var lastWidth = getWidthValue();
   (function listenWidth() {
       var width = getWidthValue();
       if (width !== lastWidth) {
           event();
           lastWidth = width;
       }
       var w = setTimeout(listenWidth, 100);
   })();

}