Blame view

bower_components/Materialize/js/transitions.js 4.69 KB
74249687   Luigi Serra   Cross browser con...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
  (function ($) {
    // Image transition function
    Materialize.fadeInImage =  function(selector){
      var element = $(selector);
      element.css({opacity: 0});
      $(element).velocity({opacity: 1}, {
          duration: 650,
          queue: false,
          easing: 'easeOutSine'
        });
      $(element).velocity({opacity: 1}, {
            duration: 1300,
            queue: false,
            easing: 'swing',
            step: function(now, fx) {
                fx.start = 100;
                var grayscale_setting = now/100;
                var brightness_setting = 150 - (100 - now)/1.75;
  
                if (brightness_setting < 100) {
                  brightness_setting = 100;
                }
                if (now >= 0) {
                  $(this).css({
                      "-webkit-filter": "grayscale("+grayscale_setting+")" + "brightness("+brightness_setting+"%)",
                      "filter": "grayscale("+grayscale_setting+")" + "brightness("+brightness_setting+"%)"
                  });
                }
            }
        });
    };
  
    // Horizontal staggered list
    Materialize.showStaggeredList = function(selector) {
      var time = 0;
      $(selector).find('li').velocity(
          { translateX: "-100px"},
          { duration: 0 });
  
      $(selector).find('li').each(function() {
        $(this).velocity(
          { opacity: "1", translateX: "0"},
          { duration: 800, delay: time, easing: [60, 10] });
        time += 120;
      });
    };
  
  
    $(document).ready(function() {
      // Hardcoded .staggered-list scrollFire
      // var staggeredListOptions = [];
      // $('ul.staggered-list').each(function (i) {
  
      //   var label = 'scrollFire-' + i;
      //   $(this).addClass(label);
      //   staggeredListOptions.push(
      //     {selector: 'ul.staggered-list.' + label,
      //      offset: 200,
      //      callback: 'showStaggeredList("ul.staggered-list.' + label + '")'});
      // });
      // scrollFire(staggeredListOptions);
  
      // HammerJS, Swipe navigation
  
      // Touch Event
      var swipeLeft = false;
      var swipeRight = false;
  
  
      // Dismissible Collections
      $('.dismissable').each(function() {
        $(this).hammer({
          prevent_default: false
        }).bind('pan', function(e) {
          if (e.gesture.pointerType === "touch") {
            var $this = $(this);
            var direction = e.gesture.direction;
            var x = e.gesture.deltaX;
            var velocityX = e.gesture.velocityX;
  
            $this.velocity({ translateX: x
                }, {duration: 50, queue: false, easing: 'easeOutQuad'});
  
            // Swipe Left
            if (direction === 4 && (x > ($this.innerWidth() / 2) || velocityX < -0.75)) {
              swipeLeft = true;
            }
  
            // Swipe Right
            if (direction === 2 && (x < (-1 * $this.innerWidth() / 2) || velocityX > 0.75)) {
              swipeRight = true;
            }
          }
        }).bind('panend', function(e) {
          // Reset if collection is moved back into original position
          if (Math.abs(e.gesture.deltaX) < ($(this).innerWidth() / 2)) {
            swipeRight = false;
            swipeLeft = false;
          }
  
          if (e.gesture.pointerType === "touch") {
            var $this = $(this);
            if (swipeLeft || swipeRight) {
              var fullWidth;
              if (swipeLeft) { fullWidth = $this.innerWidth(); }
              else { fullWidth = -1 * $this.innerWidth(); }
  
              $this.velocity({ translateX: fullWidth,
                }, {duration: 100, queue: false, easing: 'easeOutQuad', complete:
                function() {
                  $this.css('border', 'none');
                  $this.velocity({ height: 0, padding: 0,
                    }, {duration: 200, queue: false, easing: 'easeOutQuad', complete:
                      function() { $this.remove(); }
                    });
                }
              });
            }
            else {
              $this.velocity({ translateX: 0,
                }, {duration: 100, queue: false, easing: 'easeOutQuad'});
            }
            swipeLeft = false;
            swipeRight = false;
          }
        });
  
      });
  
  
      // time = 0
      // // Vertical Staggered list
      // $('ul.staggered-list.vertical li').velocity(
      //     { translateY: "100px"},
      //     { duration: 0 });
  
      // $('ul.staggered-list.vertical li').each(function() {
      //   $(this).velocity(
      //     { opacity: "1", translateY: "0"},
      //     { duration: 800, delay: time, easing: [60, 25] });
      //   time += 120;
      // });
  
      // // Fade in and Scale
      // $('.fade-in.scale').velocity(
      //     { scaleX: .4, scaleY: .4, translateX: -600},
      //     { duration: 0});
      // $('.fade-in').each(function() {
      //   $(this).velocity(
      //     { opacity: "1", scaleX: 1, scaleY: 1, translateX: 0},
      //     { duration: 800, easing: [60, 10] });
      // });
    });
  }( jQuery ));