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

代码优化问题 #2

Open
rowthan opened this issue Apr 4, 2017 · 1 comment
Open

代码优化问题 #2

rowthan opened this issue Apr 4, 2017 · 1 comment

Comments

@rowthan
Copy link

rowthan commented Apr 4, 2017

看了下你的源代码,感觉在图片大小尺寸处理上这种做法不太优雅:通过加一个父节点通过父节点去控制图片的显示大小,这种做法有两个缺点

  • 一是这样呈现的图片大小并不是真正的图片大小,多多少少都会与真实的图片大小有差。
  • 二是代码结构并不太好,不适合用于真正的生产环境,如果在项目中使用你的这个解决方法,还需要在图片结果上按照你的去做修改,开发者可能使用体验上不好,就个人而言,希望可以只需要引入dist.js就可以使用了。

其他的,看了下知乎的做法,

  • 知乎貌似是直接讲图片宽高作为参数的,但如何获取到这个尺寸不知道他怎么实现的(可能是后台api做的工作吧)。
  • 知乎是用canvas实现的,这个项目是用blur实现的哈,个人比较喜欢你这种做法。
  • 缩放效果在有的时候感觉头有点晕晕的,如果可以,希望做成一个选项方式。

其他的

  • 看到你是有监听了很多事件“scroll', 'wheel', 'mousewheel', 'resize“,没有测试过性能方面的问题,但是感觉
    是否有点冗余,而且不够优雅。之前fork过一个可视化区域加载图片懒加载代码 https://github.com/rowthan/lazy-load-img 感觉他那种做法还挺不错的。
@tomByrer
Copy link

Maybe use Element.scrollIntoView() instead of watching 'mousewheel'?
http://caniuse.com/#feat=scrollintoview

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

No branches or pull requests

2 participants