Commit 2c622f30 by Иван Кубота

slider heighter

parent b69c2994
import { AsyncAuthAjax } from "./Ajax"; import { AsyncAuthAjax } from "./Ajax";
import { API } from "../dict/Consts"; import { API } from "../dict/Consts";
Model.cards.getArray = function() {
const out = [];
let categoryItems;
for(let categoryID in this._props){
if(categoryID !== '_VERSION_'){
categoryItems = this._props[categoryID]
for(let id in categoryItems){
out.push(categoryItems[id]);
}
}
}
return out;
};
store.sub('navigation.current', (val)=>tmpStore.set('navigation.current', val)); store.sub('navigation.current', (val)=>tmpStore.set('navigation.current', val));
store.sub(['navigation.current', 'loaded.cards'], async function(page, loaded) { store.sub(['navigation.current', 'loaded.cards'], async function(page, loaded) {
......
...@@ -126,6 +126,23 @@ const Model = { ...@@ -126,6 +126,23 @@ const Model = {
history: history history: history
}; };
Model.cards.getArray = function() {
const out = [];
let categoryItems;
for(let categoryID in this._props){
if(!this._props.hasOwnProperty(categoryID))
continue;
if(categoryID !== '_VERSION_'){
categoryItems = this._props[categoryID];
for(let id in categoryItems){
out.push(categoryItems[id]);
}
}
}
return out;
};
categories.loading = {}; categories.loading = {};
const AsyncResourceLoaderQueue = function(cfg) { const AsyncResourceLoaderQueue = function(cfg) {
......
...@@ -109,6 +109,10 @@ const CardSlider = (function(){ ...@@ -109,6 +109,10 @@ const CardSlider = (function(){
let firstItem = Math.round( fromLeft / ( this.preset.cardWidth + this.world.padding )); let firstItem = Math.round( fromLeft / ( this.preset.cardWidth + this.world.padding ));
this.leftButtonDisabled.set(firstItem===0); this.leftButtonDisabled.set(firstItem===0);
this.rightButtonDisabled.set(firstItem+this.world.fullCardsCount>=this.items.length); this.rightButtonDisabled.set(firstItem+this.world.fullCardsCount>=this.items.length);
if(this.cfg.setOuterHeight){
this.scroller.style.height = ( this.hash[ firstItem ].dom.clientHeight + 40 ) + 'px';
}
//console.log(this.leftButtonDisabled.get(), this.rightButtonDisabled.get()) //console.log(this.leftButtonDisabled.get(), this.rightButtonDisabled.get())
}, },
untune: function() { untune: function() {
...@@ -200,6 +204,7 @@ const CardSlider = (function(){ ...@@ -200,6 +204,7 @@ const CardSlider = (function(){
let {lastFrom, lastTo, last} = this; let {lastFrom, lastTo, last} = this;
let {cardWidth} = this.preset; let {cardWidth} = this.preset;
let {padding} = this.world; let {padding} = this.world;
let {setOuterHeight} = this.cfg;
let from = Math.floor(scroller.scrollLeft / (cardWidth + padding) - 1), let from = Math.floor(scroller.scrollLeft / (cardWidth + padding) - 1),
count = Math.ceil(scroller.clientWidth / (cardWidth + padding)), count = Math.ceil(scroller.clientWidth / (cardWidth + padding)),
...@@ -239,7 +244,9 @@ const CardSlider = (function(){ ...@@ -239,7 +244,9 @@ const CardSlider = (function(){
} }
} }
if(from !== lastFrom){
this.lastFrom = from; this.lastFrom = from;
}
this.lastTo = to; this.lastTo = to;
this.last = true; this.last = true;
this.updateButtonsState(); this.updateButtonsState();
......
...@@ -13,6 +13,8 @@ const PaginationSliderSingleton = function(){ ...@@ -13,6 +13,8 @@ const PaginationSliderSingleton = function(){
}); });
let Slider = new CardSlider( { let Slider = new CardSlider( {
setOuterHeight: true,
name: "standardSlider", name: "standardSlider",
tpl: StandardCard, tpl: StandardCard,
preset: { preset: {
......
...@@ -40,7 +40,6 @@ const Account = D.declare('view.page.Account', () => { ...@@ -40,7 +40,6 @@ const Account = D.declare('view.page.Account', () => {
); );
let Slider = new CardSlider( { let Slider = new CardSlider( {
tpl: function (item, itemClick, n) { tpl: function (item, itemClick, n) {
return <div className="card-slider__item"> return <div className="card-slider__item">
<Card <Card
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment