Skip to content
New issue

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

fix(swiper): keep index when window resizing & code optimizating #597

Merged
merged 2 commits into from
Oct 24, 2019

Conversation

xxyan0205
Copy link
Collaborator

背景描述

  1. 当窗口尺寸变更时,Swiper会被重新初始化导致index重置。在系统键盘弹起导致的窗口尺寸的场景下[bug-report] swiper组件在屏幕resize的时候会发生重绘,返回第一页 #596,重新初始化会降低使用体验。因此在窗口尺寸时需缓存当前index,保证Swiper停留在当前索引项目上。
  2. 其他的代码优化

主要改动

  1. window resize的handler中缓存当前index,Swiper初始化以index为准来计算相关尺寸。
  2. 原来代码中开始轮播有的调用play,有的调用$_startPlay,将其统一至调用play
  3. play的第一个参数可变更Swiper轮播停留时长,但直接修改prop中的autoplay,会有警告。增加私有变量duration取代autoplay

需要注意

2,3两点的变动,会给轮播停留时长造成一定影响,需认真review相关代码!!

@codecov-io
Copy link

codecov-io commented Oct 22, 2019

Codecov Report

Merging #597 into dev will increase coverage by 0.26%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #597      +/-   ##
==========================================
+ Coverage   81.06%   81.32%   +0.26%     
==========================================
  Files          98       98              
  Lines        2830     2838       +8     
  Branches      552      555       +3     
==========================================
+ Hits         2294     2308      +14     
+ Misses        379      374       -5     
+ Partials      157      156       -1
Impacted Files Coverage Δ
components/swiper/index.vue 67.27% <66.66%> (+2.7%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5694d7f...57e65e9. Read the comment docs.

@xxyan0205 xxyan0205 merged commit 57e65e9 into dev Oct 24, 2019
@xxyan0205 xxyan0205 deleted the fix_swiper_resize branch November 2, 2019 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants