Giter Site home page Giter Site logo

picturecontrol's Introduction

picturecontrol

这个脚本主要用于在任何页面大小的情况下,都能实现页面的整屏显示,还能通过控制器,实现对设置图片的大小,以及滚动鼠标滚动等功能。 实现思路主要如下:

  1. 一开始先获取图片的实际大小,以及获取浏览器的显示页面高度$(window).height();
  2. 通过对页面的大小的触发设置,重新给图片设置高度,然后宽度自适应,以此来实现,图片的整屏显示;
  3. 通过对鼠标的滚动事件,来触发页面的移动,页面的移动是通过draggabilly插件控制的,并设置移动的范畴的containment,即可实现图片在滚动条内来回移动, 并且值得注意的是,在鼠标的滚动事件中,在火狐浏览器存在兼容性问题,所以得用isFirefox=navigator.userAgent.indexOf("Firefox")>0,进行判断是否是 火狐浏览器,通过设置DOMMouseScroll事件,既可以实现在火狐浏览器上的滚动事件;
  4. 通过一开始获取的页面实际高度,就可以可给页面设置原始的大小

后面因需求更改,就把设置页面大小的函数给屏蔽了,但也是通过不断获取实际的高度,再不断叠加实现

后续,需要在移动端实现各种功能,目前想到的方式是通过响应式来实现这个需求,不知道各位有没有更好的方式来实现,如果有可以加我微信:Cisco-LT,给我留言。

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.