@material/grid-list
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -81,3 +81,3 @@ /*! | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 50); | ||
/******/ return __webpack_require__(__webpack_require__.s = 62); | ||
/******/ }) | ||
@@ -200,85 +200,2 @@ /************************************************************************/ | ||
/***/ 19: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation__ = __webpack_require__(36); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCGridListFoundation", function() { return __WEBPACK_IMPORTED_MODULE_1__foundation__["a"]; }); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCGridList", function() { return MDCGridList; }); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/** | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
var MDCGridList = function (_MDCComponent) { | ||
_inherits(MDCGridList, _MDCComponent); | ||
function MDCGridList() { | ||
_classCallCheck(this, MDCGridList); | ||
return _possibleConstructorReturn(this, (MDCGridList.__proto__ || Object.getPrototypeOf(MDCGridList)).apply(this, arguments)); | ||
} | ||
_createClass(MDCGridList, [{ | ||
key: 'getDefaultFoundation', | ||
value: function getDefaultFoundation() { | ||
var _this2 = this; | ||
return new __WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */]({ | ||
getOffsetWidth: function getOffsetWidth() { | ||
return _this2.root_.offsetWidth; | ||
}, | ||
getOffsetWidthForTileAtIndex: function getOffsetWidthForTileAtIndex(index) { | ||
return _this2.root_.querySelectorAll(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.TILE_SELECTOR)[index].offsetWidth; | ||
}, | ||
setStyleForTilesElement: function setStyleForTilesElement(property, value) { | ||
_this2.root_.querySelector(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.TILES_SELECTOR).style[property] = value; | ||
}, | ||
registerResizeHandler: function registerResizeHandler(handler) { | ||
return window.addEventListener('resize', handler); | ||
}, | ||
deregisterResizeHandler: function deregisterResizeHandler(handler) { | ||
return window.removeEventListener('resize', handler); | ||
} | ||
}); | ||
} | ||
}], [{ | ||
key: 'attachTo', | ||
value: function attachTo(root) { | ||
return new MDCGridList(root); | ||
} | ||
}]); | ||
return MDCGridList; | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCComponent"]); | ||
/***/ }), | ||
/***/ 2: | ||
@@ -415,6 +332,92 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
/***/ 35: | ||
/***/ 20: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__foundation__ = __webpack_require__(42); | ||
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "MDCGridListFoundation", function() { return __WEBPACK_IMPORTED_MODULE_1__foundation__["a"]; }); | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCGridList", function() { return MDCGridList; }); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/** | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
var MDCGridList = function (_MDCComponent) { | ||
_inherits(MDCGridList, _MDCComponent); | ||
function MDCGridList() { | ||
_classCallCheck(this, MDCGridList); | ||
return _possibleConstructorReturn(this, (MDCGridList.__proto__ || Object.getPrototypeOf(MDCGridList)).apply(this, arguments)); | ||
} | ||
_createClass(MDCGridList, [{ | ||
key: 'getDefaultFoundation', | ||
value: function getDefaultFoundation() { | ||
var _this2 = this; | ||
return new __WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */]({ | ||
getOffsetWidth: function getOffsetWidth() { | ||
return _this2.root_.offsetWidth; | ||
}, | ||
getNumberOfTiles: function getNumberOfTiles() { | ||
return _this2.root_.querySelectorAll(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.TILE_SELECTOR).length; | ||
}, | ||
getOffsetWidthForTileAtIndex: function getOffsetWidthForTileAtIndex(index) { | ||
return _this2.root_.querySelectorAll(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.TILE_SELECTOR)[index].offsetWidth; | ||
}, | ||
setStyleForTilesElement: function setStyleForTilesElement(property, value) { | ||
_this2.root_.querySelector(__WEBPACK_IMPORTED_MODULE_1__foundation__["a" /* default */].strings.TILES_SELECTOR).style[property] = value; | ||
}, | ||
registerResizeHandler: function registerResizeHandler(handler) { | ||
return window.addEventListener('resize', handler); | ||
}, | ||
deregisterResizeHandler: function deregisterResizeHandler(handler) { | ||
return window.removeEventListener('resize', handler); | ||
} | ||
}); | ||
} | ||
}], [{ | ||
key: 'attachTo', | ||
value: function attachTo(root) { | ||
return new MDCGridList(root); | ||
} | ||
}]); | ||
return MDCGridList; | ||
}(__WEBPACK_IMPORTED_MODULE_0__material_base__["MDCComponent"]); | ||
/***/ }), | ||
/***/ 41: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return strings; }); | ||
@@ -443,3 +446,3 @@ /** | ||
/***/ 36: | ||
/***/ 42: | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
@@ -449,3 +452,3 @@ | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__material_base__ = __webpack_require__(0); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__(35); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__constants__ = __webpack_require__(41); | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -496,2 +499,6 @@ | ||
}, | ||
getNumberOfTiles: function getNumberOfTiles() { | ||
return (/* number */0 | ||
); | ||
}, | ||
getOffsetWidthForTileAtIndex: function getOffsetWidthForTileAtIndex() { | ||
@@ -547,2 +554,5 @@ return (/* index: number */ /* number */0 | ||
value: function alignCenter_() { | ||
if (this.adapter_.getNumberOfTiles() == 0) { | ||
return; | ||
} | ||
var gridWidth = this.adapter_.getOffsetWidth(); | ||
@@ -562,6 +572,6 @@ var itemWidth = this.adapter_.getOffsetWidthForTileAtIndex(0); | ||
/***/ 50: | ||
/***/ 62: | ||
/***/ (function(module, exports, __webpack_require__) { | ||
module.exports = __webpack_require__(19); | ||
module.exports = __webpack_require__(20); | ||
@@ -568,0 +578,0 @@ |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.gridList=t():(e.mdc=e.mdc||{},e.mdc.gridList=t())}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s=50)}({0:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);n.d(t,"MDCFoundation",function(){return r.a});var i=n(2);n.d(t,"MDCComponent",function(){return i.a})},1:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.adapter_=t}return i(e,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),i(e,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),e}();t.a=o},19:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=n(0),a=n(36);n.d(t,"MDCGridListFoundation",function(){return a.a}),n.d(t,"MDCGridList",function(){return s});var f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),f(t,[{key:"getDefaultFoundation",value:function(){var e=this;return new a.a({getOffsetWidth:function(){return e.root_.offsetWidth},getOffsetWidthForTileAtIndex:function(t){return e.root_.querySelectorAll(a.a.strings.TILE_SELECTOR)[t].offsetWidth},setStyleForTilesElement:function(t,n){e.root_.querySelector(a.a.strings.TILES_SELECTOR).style[t]=n},registerResizeHandler:function(e){return window.addEventListener("resize",e)},deregisterResizeHandler:function(e){return window.removeEventListener("resize",e)}})}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(u.MDCComponent)},2:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(1),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;r(this,e),this.root_=t;for(var i=arguments.length,o=Array(i>2?i-2:0),u=2;u<i;u++)o[u-2]=arguments[u];this.initialize.apply(this,o),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return o(e,null,[{key:"attachTo",value:function(t){return new e(t,new i.a)}}]),o(e,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(e,t){this.root_.addEventListener(e,t)}},{key:"unlisten",value:function(e,t){this.root_.removeEventListener(e,t)}},{key:"emit",value:function(e,t){var n=void 0;"function"==typeof CustomEvent?n=new CustomEvent(e,{detail:t}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!1,t)),this.root_.dispatchEvent(n)}}]),e}();t.a=u},35:function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r={TILES_SELECTOR:".mdc-grid-list__tiles",TILE_SELECTOR:".mdc-grid-tile"}},36:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(0),a=n(35),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,f(t.defaultAdapter,e)));return n.resizeHandler_=function(){return n.alignCenter()},n.resizeFrame_=0,n}return o(t,e),s(t,null,[{key:"strings",get:function(){return a.a}},{key:"defaultAdapter",get:function(){return{getOffsetWidth:function(){return 0},getOffsetWidthForTileAtIndex:function(){return 0},setStyleForTilesElement:function(){},registerResizeHandler:function(){},deregisterResizeHandler:function(){}}}}]),s(t,[{key:"init",value:function(){this.alignCenter(),this.adapter_.registerResizeHandler(this.resizeHandler_)}},{key:"destroy",value:function(){this.adapter_.deregisterResizeHandler(this.resizeHandler_)}},{key:"alignCenter",value:function(){var e=this;0!==this.resizeFrame_&&cancelAnimationFrame(this.resizeFrame_),this.resizeFrame_=requestAnimationFrame(function(){e.alignCenter_(),e.resizeFrame_=0})}},{key:"alignCenter_",value:function(){var e=this.adapter_.getOffsetWidth(),t=this.adapter_.getOffsetWidthForTileAtIndex(0),n=t*Math.floor(e/t);this.adapter_.setStyleForTilesElement("width",n+"px")}}]),t}(u.MDCFoundation);t.a=c},50:function(e,t,n){e.exports=n(19)}})}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.gridList=t():(e.mdc=e.mdc||{},e.mdc.gridList=t())}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s=62)}({0:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);n.d(t,"MDCFoundation",function(){return r.a});var i=n(2);n.d(t,"MDCComponent",function(){return i.a})},1:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};r(this,e),this.adapter_=t}return i(e,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),i(e,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),e}();t.a=o},2:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=n(1),o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;r(this,e),this.root_=t;for(var i=arguments.length,o=Array(i>2?i-2:0),u=2;u<i;u++)o[u-2]=arguments[u];this.initialize.apply(this,o),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return o(e,null,[{key:"attachTo",value:function(t){return new e(t,new i.a)}}]),o(e,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(e,t){this.root_.addEventListener(e,t)}},{key:"unlisten",value:function(e,t){this.root_.removeEventListener(e,t)}},{key:"emit",value:function(e,t){var n=void 0;"function"==typeof CustomEvent?n=new CustomEvent(e,{detail:t}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(e,!1,!1,t)),this.root_.dispatchEvent(n)}}]),e}();t.a=u},20:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var u=n(0),a=n(42);n.d(t,"MDCGridListFoundation",function(){return a.a}),n.d(t,"MDCGridList",function(){return s});var f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(e){function t(){return r(this,t),i(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return o(t,e),f(t,[{key:"getDefaultFoundation",value:function(){var e=this;return new a.a({getOffsetWidth:function(){return e.root_.offsetWidth},getNumberOfTiles:function(){return e.root_.querySelectorAll(a.a.strings.TILE_SELECTOR).length},getOffsetWidthForTileAtIndex:function(t){return e.root_.querySelectorAll(a.a.strings.TILE_SELECTOR)[t].offsetWidth},setStyleForTilesElement:function(t,n){e.root_.querySelector(a.a.strings.TILES_SELECTOR).style[t]=n},registerResizeHandler:function(e){return window.addEventListener("resize",e)},deregisterResizeHandler:function(e){return window.removeEventListener("resize",e)}})}}],[{key:"attachTo",value:function(e){return new t(e)}}]),t}(u.MDCComponent)},41:function(e,t,n){"use strict";n.d(t,"a",function(){return r});var r={TILES_SELECTOR:".mdc-grid-list__tiles",TILE_SELECTOR:".mdc-grid-tile"}},42:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=n(0),a=n(41),f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},s=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=function(e){function t(e){r(this,t);var n=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,f(t.defaultAdapter,e)));return n.resizeHandler_=function(){return n.alignCenter()},n.resizeFrame_=0,n}return o(t,e),s(t,null,[{key:"strings",get:function(){return a.a}},{key:"defaultAdapter",get:function(){return{getOffsetWidth:function(){return 0},getNumberOfTiles:function(){return 0},getOffsetWidthForTileAtIndex:function(){return 0},setStyleForTilesElement:function(){},registerResizeHandler:function(){},deregisterResizeHandler:function(){}}}}]),s(t,[{key:"init",value:function(){this.alignCenter(),this.adapter_.registerResizeHandler(this.resizeHandler_)}},{key:"destroy",value:function(){this.adapter_.deregisterResizeHandler(this.resizeHandler_)}},{key:"alignCenter",value:function(){var e=this;0!==this.resizeFrame_&&cancelAnimationFrame(this.resizeFrame_),this.resizeFrame_=requestAnimationFrame(function(){e.alignCenter_(),e.resizeFrame_=0})}},{key:"alignCenter_",value:function(){if(0!=this.adapter_.getNumberOfTiles()){var e=this.adapter_.getOffsetWidth(),t=this.adapter_.getOffsetWidthForTileAtIndex(0),n=t*Math.floor(e/t);this.adapter_.setStyleForTilesElement("width",n+"px")}}}]),t}(u.MDCFoundation);t.a=c},62:function(e,t,n){e.exports=n(20)}})}); |
@@ -28,2 +28,3 @@ /** | ||
getOffsetWidth: () => /* number */ 0, | ||
getNumberOfTiles: () => /* number */ 0, | ||
getOffsetWidthForTileAtIndex: (/* index: number */) => /* number */ 0, | ||
@@ -57,2 +58,5 @@ setStyleForTilesElement: (/* property: string, value: string */) => {}, | ||
alignCenter_() { | ||
if (this.adapter_.getNumberOfTiles() == 0) { | ||
return; | ||
} | ||
const gridWidth = this.adapter_.getOffsetWidth(); | ||
@@ -59,0 +63,0 @@ const itemWidth = this.adapter_.getOffsetWidthForTileAtIndex(0); |
@@ -31,2 +31,5 @@ /** | ||
getOffsetWidth: () => this.root_.offsetWidth, | ||
getNumberOfTiles: () => { | ||
return this.root_.querySelectorAll(MDCGridListFoundation.strings.TILE_SELECTOR).length; | ||
}, | ||
getOffsetWidthForTileAtIndex: (index) => { | ||
@@ -33,0 +36,0 @@ return this.root_.querySelectorAll(MDCGridListFoundation.strings.TILE_SELECTOR)[index].offsetWidth; |
{ | ||
"name": "@material/grid-list", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "The Material Components for the web grid list component", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -261,2 +261,3 @@ # MDC Grid list | ||
| `getOffsetWidth() => number` | Get root element `mdc-grid-list` offsetWidth. | | ||
| `getNumberOfTiles() => number` | Get the number of mdc-grid-tile elements contained within the grid list. | | ||
| `getOffsetWidthForTileAtIndex(index: number) => number` | Get offsetWidth of `mdc-grid-tile` at specified index. | | ||
@@ -263,0 +264,0 @@ | `setStyleForTilesElement(property: string, value: number) => void` | Set `mdc-grid-list__tiles` style property to provided value. | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
68382
1073
265
0