Giter VIP home page Giter VIP logo

fly-image's Introduction

fly-image

会飞的图片查看器

fly-image

实际效果比动图中更流畅,因为动图太大,因此压缩了质量,具体效果以实际运行为准。

下载/使用

npm i fly-image
import FlyImage from 'fly-image'
const options = {
  modal: false,
  size: 0.5
}
new FlyImage(img, options)

特性

  • 飞行效果
  • 自动计算,展示合适的大小

options

属性名 类型 说明 默认值 可选值
modal boolean 是否显示遮罩效果 true -
zIndex number z-index 10000 -
size number 图片宽度 / 容器宽度,默认为0,图片宽度动态计算 0 [0, N]
offset number 图片全屏显示时,距离四周的偏移量(px) 20 -
speed number 飞行速度(ms) 250 -
hide boolean 是否隐藏原图 false -

原理

fly-image的实现原理

性能问题

  • 事件绑定
  • 资源回收

如何提高性能?

  • 使用HTMLImageElement.naturalWidthapi,减少请求次数
  • 提前准备上下文数据
  • 只准备一次上下文数据,不频繁生成

fly-image's People

Contributors

shoppingzh avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.