We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 0.9.5 Environment win10 Reproduction link https://pktsbn.run.stackblitz.io/ Steps to reproduce https://pktsbn.run.stackblitz.io/ What is expected? CarouselSlide高度正常 What is actually happening? CarouselSlide在父元素没有ng动画时,宽度为0 Other
纵向滑动时,宽度是auto未出现问题
carouselInit函数中 v.width = this.vertical ? 'auto' : this._rationWidth - this.cellSpacing;
横向滑动时,当父组件有ng的动画时,在afterviewinit后会自动插入class:'ng-star-inserted',dom发生了变化,会调用afterviewInit里面的callback函数,_rationWidth就有数值了,但是在父组件没有ng的动画,BrowserAnimationsModule不会给CarouselSlide增加class:ng-star-inserted,也就无法触发callback,然后this._rationWidth数值一直是0,v.width就是0了
carouselInit(items) { this.infinite = this.infinite === undefined ? true : this.infinite; this._nodeArr = items['_results']; this.dragging = this._nodeArr.length > 1 && this.dragging ? this.dragging : false; this.dragging = this.dragging ? this.dragging : false; if (this._nodeArr.length > 1) { this._lastIndex = this._nodeArr.length - 1; setTimeout(() => { this._nodeArr.forEach((v, index) => { v.width = this.vertical ? 'auto' : this._rationWidth - this.cellSpacing; v.left = this.vertical ? 0 : index === this._lastIndex ? -this._rationWidth : index * this._rationWidth; v.top = this.vertical ? (index === this._lastIndex ? -this._rationWidth : index * this._rationWidth) : 0; v.margin = this.vertical ? `${this.cellSpacing / 2}px auto` : `auto ${this.cellSpacing / 2}px`; }); this.startTimer(); }, 0); } else if (this._nodeArr.length === 1) { setTimeout(() => { this._nodeArr.forEach((v, index) => { v.width = this._rationWidth - this.cellSpacing; v.left = 0; v.top = 0; v.margin = `auto ${this.cellSpacing / 2}px`; }); }, 0); } }
方案: 给carousel的component装饰器加上动画好使,不过这个ng-star-inserted是ng5出现的,未来不知道会不会去掉,有一点风险
animations: [ trigger('', []) // 利用动画增加的css类ng-star-inserted首次触发MutationObserver ]
或者在afterviewinit里给_rationWidth等变量做callback中那样的赋值
The text was updated successfully, but these errors were encountered:
你好,https://pktsbn.run.stackblitz.io/ 这个链接我打不开,请问一下具体什么情况下“父元素没有ng动画”?
Sorry, something went wrong.
我正准备按照动画这个方案提pr,从官方走马灯demo的基本用法点进stackblitz就能看到,图片没有加载出来
是问什么场景不用ng动画吗?开发的时候某个懒加载的模块很有可能不会使用trigger,走马灯的宽度就没了
已修复:#67
BronzeCui
No branches or pull requests
Version
0.9.5
Environment
win10
Reproduction link
https://pktsbn.run.stackblitz.io/
Steps to reproduce
https://pktsbn.run.stackblitz.io/
What is expected?
CarouselSlide高度正常
What is actually happening?
CarouselSlide在父元素没有ng动画时,宽度为0
Other
纵向滑动时,宽度是auto未出现问题
横向滑动时,当父组件有ng的动画时,在afterviewinit后会自动插入class:'ng-star-inserted',dom发生了变化,会调用afterviewInit里面的callback函数,_rationWidth就有数值了,但是在父组件没有ng的动画,BrowserAnimationsModule不会给CarouselSlide增加class:ng-star-inserted,也就无法触发callback,然后this._rationWidth数值一直是0,v.width就是0了
方案:
给carousel的component装饰器加上动画好使,不过这个ng-star-inserted是ng5出现的,未来不知道会不会去掉,有一点风险
或者在afterviewinit里给_rationWidth等变量做callback中那样的赋值
The text was updated successfully, but these errors were encountered: