mui-sass 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f15b9a1fa1efa32c0e41fd7afbf1336ef50e1798
4
- data.tar.gz: 3fc0508472fb1ca878e4b54286f74dd15b9dc9c6
3
+ metadata.gz: b9ce817312c52507d3f3802adf56ef3a1909ec19
4
+ data.tar.gz: c6f73b404233163cc052e563d48d6dfe30612703
5
5
  SHA512:
6
- metadata.gz: a632e35f027d90eea201310351faf54f79ea151bcc6bc21471513c3cb9c6d854eaf6d07ef07c7562b3e987f5cbe53e2fa3e75a6050fad3305237a035902774c6
7
- data.tar.gz: a9d6187606fecbc19fd673a7ef2ca70c5f3472c824303f4c6a32b4a21fe7f4bcd98a1f83f1cd49851d9408ce41feae67b8a1a0b905661099a4a9a1f491b3ec75
6
+ metadata.gz: 6f588b1fd60efca14a051a91a4a3fb8a37972150babc7eaff6a41e9e156ba69ebf66b58022194cc5644588de6b6554f60dd0fd951d205f5a080f5491835d4d8b
7
+ data.tar.gz: 244b9acf89a46b989d83cea87a0aa5c654093793698270de56f559f273146304790328cce85247617f7ec9e30e153dad543e293a3ff8e66c3516877f7fde7b9d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.6.1 (2016-06-27)
2
+
3
+ - Update assets to match upstream version
4
+
5
+ Framework version: MUI v0.6.1
6
+
1
7
  ## 0.6.0 (2016-06-27)
2
8
 
3
9
  - Update assets to match upstream version
@@ -1,5 +1,5 @@
1
1
  module Mui
2
2
  module Sass
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
4
4
  end
5
5
  end
@@ -217,72 +217,81 @@ function jqLiteType(somevar) {
217
217
  /**
218
218
  * Attach an event handler to a DOM element
219
219
  * @param {Element} element - The DOM element.
220
- * @param {string} type - The event type name.
220
+ * @param {string} events - Space separated event names.
221
221
  * @param {Function} callback - The callback function.
222
222
  * @param {Boolean} useCapture - Use capture flag.
223
223
  */
224
- function jqLiteOn(element, type, callback, useCapture) {
224
+ function jqLiteOn(element, events, callback, useCapture) {
225
225
  useCapture = (useCapture === undefined) ? false : useCapture;
226
226
 
227
- // add to DOM
228
- element.addEventListener(type, callback, useCapture);
227
+ var cache = element._muiEventCache = element._muiEventCache || {};
228
+
229
+ events.split(' ').map(function(event) {
230
+ // add to DOM
231
+ element.addEventListener(event, callback, useCapture);
229
232
 
230
- // add to cache
231
- var cache = element._muiEventCache = element._muiEventCache || {};
232
- cache[type] = cache[type] || [];
233
- cache[type].push([callback, useCapture]);
233
+ // add to cache
234
+ cache[event] = cache[event] || [];
235
+ cache[event].push([callback, useCapture]);
236
+ });
234
237
  }
235
238
 
236
239
 
237
240
  /**
238
241
  * Remove an event handler from a DOM element
239
242
  * @param {Element} element - The DOM element.
240
- * @param {string} type - The event type name.
243
+ * @param {string} events - Space separated event names.
241
244
  * @param {Function} callback - The callback function.
242
245
  * @param {Boolean} useCapture - Use capture flag.
243
246
  */
244
- function jqLiteOff(element, type, callback, useCapture) {
247
+ function jqLiteOff(element, events, callback, useCapture) {
245
248
  useCapture = (useCapture === undefined) ? false : useCapture;
246
249
 
247
250
  // remove from cache
248
251
  var cache = element._muiEventCache = element._muiEventCache || {},
249
- argsList = cache[type] || [],
252
+ argsList,
250
253
  args,
251
254
  i;
252
255
 
253
- i = argsList.length;
254
- while (i--) {
255
- args = argsList[i];
256
+ events.split(' ').map(function(event) {
257
+ argsList = cache[event] || [];
256
258
 
257
- // remove all events if callback is undefined
258
- if (callback === undefined ||
259
- (args[0] === callback && args[1] === useCapture)) {
259
+ i = argsList.length;
260
+ while (i--) {
261
+ args = argsList[i];
260
262
 
261
- // remove from cache
262
- argsList.splice(i, 1);
263
-
264
- // remove from DOM
265
- element.removeEventListener(type, args[0], args[1]);
263
+ // remove all events if callback is undefined
264
+ if (callback === undefined ||
265
+ (args[0] === callback && args[1] === useCapture)) {
266
+
267
+ // remove from cache
268
+ argsList.splice(i, 1);
269
+
270
+ // remove from DOM
271
+ element.removeEventListener(event, args[0], args[1]);
272
+ }
266
273
  }
267
- }
274
+ });
268
275
  }
269
276
 
270
277
 
271
278
  /**
272
- * Attach an event hander which will only execute once
279
+ * Attach an event hander which will only execute once per element per event
273
280
  * @param {Element} element - The DOM element.
274
- * @param {string} type - The event type name.
281
+ * @param {string} events - Space separated event names.
275
282
  * @param {Function} callback - The callback function.
276
283
  * @param {Boolean} useCapture - Use capture flag.
277
284
  */
278
- function jqLiteOne(element, type, callback, useCapture) {
279
- jqLiteOn(element, type, function onFn(ev) {
280
- // execute callback
281
- if (callback) callback.apply(this, arguments);
285
+ function jqLiteOne(element, events, callback, useCapture) {
286
+ events.split(' ').map(function(event) {
287
+ jqLiteOn(element, event, function onFn(ev) {
288
+ // execute callback
289
+ if (callback) callback.apply(this, arguments);
282
290
 
283
- // remove wrapper
284
- jqLiteOff(element, type, onFn);
285
- }, useCapture);
291
+ // remove wrapper
292
+ jqLiteOff(element, event, onFn);
293
+ }, useCapture);
294
+ });
286
295
  }
287
296
 
288
297
 
@@ -595,12 +604,10 @@ function onNodeInsertedFn(callbackFn) {
595
604
 
596
605
  // initalize listeners
597
606
  if (nodeInsertedCallbacks._initialized === undefined) {
598
- var doc = document;
599
-
600
- jqLite.on(doc, 'animationstart', animationHandlerFn);
601
- jqLite.on(doc, 'mozAnimationStart', animationHandlerFn);
602
- jqLite.on(doc, 'webkitAnimationStart', animationHandlerFn);
607
+ var doc = document,
608
+ events = 'animationstart mozAnimationStart webkitAnimationStart';
603
609
 
610
+ jqLite.on(doc, events, animationHandlerFn);
604
611
  nodeInsertedCallbacks._initialized = true;
605
612
  }
606
613
  }
@@ -728,6 +735,16 @@ function disableScrollLockFn() {
728
735
  }
729
736
 
730
737
 
738
+ /**
739
+ * requestAnimationFrame polyfilled
740
+ * @param {Function} callback - The callback function
741
+ */
742
+ function requestAnimationFrame(callback) {
743
+ if (window.requestAnimationFrame) requestAnimationFrame(callback);
744
+ else setTimeout(callback, 0);
745
+ }
746
+
747
+
731
748
  /**
732
749
  * Define the module API
733
750
  */
@@ -759,6 +776,9 @@ module.exports = {
759
776
  /** Raise MUI error */
760
777
  raiseError: raiseErrorFn,
761
778
 
779
+ /** Request animation frame */
780
+ requestAnimationFrame: requestAnimationFrame,
781
+
762
782
  /** Support Pointer Events check */
763
783
  supportsPointerEvents: supportsPointerEventsFn
764
784
  };
@@ -1086,7 +1106,10 @@ var jqLite = require('./lib/jqLite'),
1086
1106
  btnClass = 'mui-btn',
1087
1107
  btnFABClass = 'mui-btn--fab',
1088
1108
  rippleClass = 'mui-ripple-effect',
1089
- animationName = 'mui-btn-inserted';
1109
+ supportsTouch = 'ontouchstart' in document.documentElement,
1110
+ mouseDownEvents = (supportsTouch) ? 'touchstart' : 'mousedown',
1111
+ mouseUpEvents = (supportsTouch) ? 'touchend' : 'mouseup mouseleave',
1112
+ animationDuration = 600;
1090
1113
 
1091
1114
 
1092
1115
  /**
@@ -1102,49 +1125,102 @@ function initialize(buttonEl) {
1102
1125
  if (buttonEl.tagName === 'INPUT') return;
1103
1126
 
1104
1127
  // attach event handler
1105
- jqLite.on(buttonEl, 'touchstart', eventHandler);
1106
- jqLite.on(buttonEl, 'mousedown', eventHandler);
1128
+ jqLite.on(buttonEl, mouseDownEvents, mouseDownHandler);
1107
1129
  }
1108
1130
 
1109
1131
 
1110
1132
  /**
1111
- * Event handler
1133
+ * MouseDown Event handler.
1112
1134
  * @param {Event} ev - The DOM event
1113
1135
  */
1114
- function eventHandler(ev) {
1136
+ function mouseDownHandler(ev) {
1115
1137
  // only left clicks
1116
- if (ev.button !== 0) return;
1138
+ if (ev.type === 'mousedown' && ev.button !== 0) return;
1117
1139
 
1118
1140
  var buttonEl = this;
1119
1141
 
1120
1142
  // exit if button is disabled
1121
1143
  if (buttonEl.disabled === true) return;
1122
1144
 
1123
- // de-dupe touchstart and mousedown with 100msec flag
1124
- if (buttonEl.touchFlag === true) {
1125
- return;
1126
- } else {
1127
- buttonEl.touchFlag = true;
1145
+ // add mouseup event to button once
1146
+ if (!buttonEl.muiMouseUp) {
1147
+ jqLite.on(buttonEl, mouseUpEvents, mouseUpHandler);
1148
+ buttonEl.muiMouseUp = true;
1149
+ }
1150
+
1151
+ // create ripple element
1152
+ var rippleEl = createRippleEl(ev, buttonEl);
1153
+
1154
+ buttonEl.appendChild(rippleEl);
1155
+
1156
+ // animate in
1157
+ util.requestAnimationFrame(function() {
1158
+ jqLite.addClass(rippleEl, 'mui--animate-in mui--active');
1159
+ });
1160
+ }
1161
+
1162
+
1163
+ /**
1164
+ * MouseUp event handler.
1165
+ * @param {Event} ev - The DOM event
1166
+ */
1167
+ function mouseUpHandler(ev) {
1168
+ var children = this.children,
1169
+ i = children.length,
1170
+ rippleEls = [],
1171
+ el;
1172
+
1173
+ // animate out ripples
1174
+ while (i--) {
1175
+ el = children[i];
1176
+ if (jqLite.hasClass(el, rippleClass)) {
1177
+ jqLite.addClass(el, 'mui--animate-out');
1178
+ rippleEls.push(el);
1179
+ }
1180
+ }
1181
+
1182
+ // remove ripples after animation
1183
+ if (rippleEls.length) {
1128
1184
  setTimeout(function() {
1129
- buttonEl.touchFlag = false;
1130
- }, 100);
1185
+ var i = rippleEls.length,
1186
+ el,
1187
+ parentNode;
1188
+
1189
+ // remove elements
1190
+ while (i--) {
1191
+ el = rippleEls[i];
1192
+ parentNode = el.parentNode;
1193
+ if (parentNode) parentNode.removeChild(el);
1194
+ }
1195
+ }, animationDuration);
1131
1196
  }
1197
+ }
1132
1198
 
1133
- var rippleEl = document.createElement('div');
1134
- rippleEl.className = rippleClass;
1135
1199
 
1200
+ /**
1201
+ * Create ripple element
1202
+ * @param {Element} - buttonEl - The button element.
1203
+ */
1204
+ function createRippleEl(ev, buttonEl) {
1205
+ // get (x, y) position of click
1136
1206
  var offset = jqLite.offset(buttonEl),
1137
- xPos = ev.pageX - offset.left,
1138
- yPos = ev.pageY - offset.top,
1207
+ clickEv = (ev.type === 'touchstart') ? ev.touches[0] : ev,
1208
+ xPos = clickEv.pageX - offset.left,
1209
+ yPos = clickEv.pageY - offset.top,
1139
1210
  diameter,
1140
- radius;
1211
+ radius,
1212
+ rippleEl;
1141
1213
 
1142
- // get height
1214
+ // choose diameter
1143
1215
  if (jqLite.hasClass(buttonEl, btnFABClass)) diameter = offset.height / 2;
1144
1216
  else diameter = offset.height;
1145
1217
 
1218
+ // create element
1219
+ rippleEl = document.createElement('div'),
1220
+ rippleEl.className = rippleClass;
1221
+
1146
1222
  radius = diameter / 2;
1147
-
1223
+
1148
1224
  jqLite.css(rippleEl, {
1149
1225
  height: diameter + 'px',
1150
1226
  width: diameter + 'px',
@@ -1152,12 +1228,7 @@ function eventHandler(ev) {
1152
1228
  left: xPos - radius + 'px'
1153
1229
  });
1154
1230
 
1155
- buttonEl.appendChild(rippleEl);
1156
-
1157
- window.setTimeout(function() {
1158
- var parentNode = rippleEl.parentNode;
1159
- if (parentNode) parentNode.removeChild(rippleEl);
1160
- }, 2000);
1231
+ return rippleEl;
1161
1232
  }
1162
1233
 
1163
1234
 
@@ -1734,8 +1805,7 @@ function initialize(inputEl) {
1734
1805
  if (inputEl.value.length) jqLite.addClass(inputEl, notEmptyClass);
1735
1806
  else jqLite.addClass(inputEl, emptyClass);
1736
1807
 
1737
- jqLite.on(inputEl, 'input', inputHandler);
1738
- jqLite.on(inputEl, 'change', inputHandler);
1808
+ jqLite.on(inputEl, 'input change', inputHandler);
1739
1809
 
1740
1810
  // add dirty class on focus
1741
1811
  jqLite.on(inputEl, 'focus', function(){jqLite.addClass(this, dirtyClass);});
@@ -87,7 +87,7 @@
87
87
 
88
88
  }
89
89
 
90
- &:active {
90
+ &:active:hover {
91
91
  @include x-btn-box-shadow-active();
92
92
  }
93
93
 
@@ -120,7 +120,8 @@
120
120
 
121
121
  &:hover,
122
122
  &:focus,
123
- &:active {
123
+ &:active,
124
+ &:active:hover {
124
125
  box-shadow: none;
125
126
  background-color: $mui-btn-flat-bg-color-hover;
126
127
  }
@@ -9,24 +9,30 @@
9
9
  position: absolute;
10
10
  border-radius: 50%;
11
11
  pointer-events: none;
12
- opacity: 0;
13
- animation: mui-ripple-animation 2s;
14
- }
15
12
 
16
- @keyframes mui-ripple-animation {
17
- from {
18
- transform: scale(1);
19
- opacity: 0.4;
13
+ // initial properties
14
+ opacity: 0.4;
15
+ transform: scale(1);
16
+
17
+ &.mui--animate-in {
18
+ opacity: 0;
19
+ transform: scale(7);
20
+ transition: transform 0.3s cubic-bezier(0, 0, 0.2, 1),
21
+ opacity 0.6s cubic-bezier(0, 0, 0.2, 1);
20
22
  }
21
- to {
22
- transform: scale(100);
23
+
24
+ &.mui--active {
25
+ opacity: 0.3;
26
+ }
27
+
28
+ &.mui--animate-out {
23
29
  opacity: 0;
30
+ transition: opacity 0.6s cubic-bezier(0, 0, 0.2, 1);
24
31
  }
25
32
  }
26
33
 
27
34
 
28
35
 
29
-
30
36
  // ============================================================================
31
37
  // BUTTON-SPECIFIC STYLES
32
38
  // ============================================================================
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mui-sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Tarasov