日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

NiceScroll文档阅读笔记-NiceScroll(3.7.6)基本使用

發布時間:2025/3/15 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NiceScroll文档阅读笔记-NiceScroll(3.7.6)基本使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

官方已經給出很好的文檔了。在此本人總結下,方便以后查閱:

GitHub - inuyaksa/jquery.nicescroll: nicescroll plugin for jquery - scrollbars like iphone/ipad

nicescroll是一個jquery的插件,需要先包含jquery,再使用這框架,NiceScroller可用于jQuery1.x/2.x/3.x版本,但不能在slim版本中使用。

使用

首先需要先保護jQuery,,然后再把jquery.nicesroll.min.js和zoomico.png放到項目中,注意,zoomico.png要和jquery.nicescroll.min.js放到同一個目錄下。

注意:如果不需要使用NiceScroll提供了zoom功能,就不需要加入zoomic.png圖片。

通常在document的ready的時候的初始化NiceScroll

// 1. Simple mode, it styles document scrollbar:【直接替換傳統的scroll】 $(function() { $("body").niceScroll(); });// 2. Instance with object returned:【獲取body中替換的NiceScroll對象】 var nice = false; $(function() { nice = $("body").niceScroll(); });// 3. Style a DIV and change cursor color:【改變div的style】 $(function() { $("#thisdiv").niceScroll({cursorcolor:"#00F"}); });// 4. DIV with "wrapper", formed by two divs, the first is the vieport, the latter is the content:【div嵌套時的用法,外層的叫viewport,內層的是warpper】 $(function() {$("#viewportdiv").niceScroll("#wrapperdiv",{cursorcolor:"#00F"}); });// 5. Get nicescroll object:【獲取NiceScroll對象】 var nice = $("#mydiv").getNiceScroll();// 6. Hide scrollbars:【隱藏Scrollbars】 $("#mydiv").getNiceScroll().hide();// 7. Check for scrollbars resize (when content or position have changed):【當內容和位置發生改變時,就要使用resize這個函數了】 $("#mydiv").getNiceScroll().resize();// 8. Scrolling to a position:【獲取sroll的位置,x軸和y軸】 $("#mydiv").getNiceScroll(0).doScrollLeft(x, duration); // Scroll X Axis $("#mydiv").getNiceScroll(0).doScrollTop(y, duration); // Scroll Y Axis

NiceScroll相關參數

$("#thisdiv").niceScroll({cursorcolor: "#424242", // change cursor color in hexcursoropacitymin: 0, // change opacity when cursor is inactive (scrollabar "hidden" state), range from 1 to 0cursoropacitymax: 1, // change opacity when cursor is active (scrollabar "visible" state), range from 1 to 0cursorwidth: "5px", // cursor width in pixel (you can also write "5px")cursorborder: "1px solid #fff", // css definition for cursor bordercursorborderradius: "5px", // border radius in pixel for cursorzindex: "auto" | [number], // change z-index for scrollbar divscrollspeed: 60, // scrolling speedmousescrollstep: 40, // scrolling speed with mouse wheel (pixel)touchbehavior: false, // DEPRECATED!! use "emulatetouch"emulatetouch: false, // enable cursor-drag scrolling like touch devices in desktop computerhwacceleration: true, // use hardware accelerated scroll when supportedboxzoom: false, // enable zoom for box contentdblclickzoom: true, // (only when boxzoom=true) zoom activated when double click on boxgesturezoom: true, // (only when boxzoom=true and with touch devices) zoom activated when pinch out/in on boxgrabcursorenabled: true // (only when touchbehavior=true) display "grab" iconautohidemode: true, // how hide the scrollbar works, possible values: true | // hide when no scrolling"cursor" | // only cursor hiddenfalse | // do not hide,"leave" | // hide only if pointer leaves content"hidden" | // hide always"scroll", // show only on scroll background: "", // change css for rail backgroundiframeautoresize: true, // autoresize iframe on load eventcursorminheight: 32, // set the minimum cursor height (pixel)preservenativescrolling: true, // you can scroll native scrollable areas with mouse, bubbling mouse wheel eventrailoffset: false, // you can add offset top/left for rail positionbouncescroll: false, // (only hw accell) enable scroll bouncing at the end of content as mobile-like spacebarenabled: true, // enable page down scrolling when space bar has pressedrailpadding: { top: 0, right: 0, left: 0, bottom: 0 }, // set padding for rail bardisableoutline: true, // for chrome browser, disable outline (orange highlight) when selecting a div with nicescrollhorizrailenabled: true, // nicescroll can manage horizontal scrollrailalign: right, // alignment of vertical railrailvalign: bottom, // alignment of horizontal railenabletranslate3d: true, // nicescroll can use css translate to scroll contentenablemousewheel: true, // nicescroll can manage mouse wheel eventsenablekeyboard: true, // nicescroll can manage keyboard eventssmoothscroll: true, // scroll with ease movementsensitiverail: true, // click on rail make a scrollenablemouselockapi: true, // can use mouse caption lock API (same issue on object dragging)cursorfixedheight: false, // set fixed height for cursor in pixelhidecursordelay: 400, // set the delay in microseconds to fading out scrollbarsdirectionlockdeadzone: 6, // dead zone in pixels for direction lock activationnativeparentscrolling: true, // detect bottom of content and let parent to scroll, as native scroll doesenablescrollonselection: true, // enable auto-scrolling of content when selection textcursordragspeed: 0.3, // speed of selection when dragged with cursorrtlmode: "auto", // horizontal div scrolling starts at left sidecursordragontouch: false, // drag cursor in touch / touchbehavior mode alsooneaxismousemode: "auto", // it permits horizontal scrolling with mousewheel on horizontal only content, if false (vertical-only) mousewheel don't scroll horizontally, if value is auto detects two-axis mousescriptpath: "" // define custom path for boxmode icons ("" => same script path)preventmultitouchscrolling: true // prevent scrolling on multitouch eventsdisablemutationobserver: false // force MutationObserver disabled,enableobserver: true // enable DOM changing observer, it tries to resize/hide/show when parent or content div had changedscrollbarid: false // set a custom ID for nicescroll bars });

此處用個表簡單解釋下:

propertyvaluedescription
cursorcolor"#424242"改變光標顏色(十六進制)
cursoropacitymin0當光標是無效狀態時改變其透明度,范圍從1到0
cursoropacitymax1當光標是有效狀態時改變其透明度,范圍從1到0
cursorwidth"5px"光標的寬度為5像素
cursorborder"1px solid #fff"使用css定義光標包邊
cursorborderradius"5px"光標的包邊半徑(改包邊為圓弧)
zindex"auto" | [number]改變光標div的z-index
scrollspeed60光標速率
mousescrollstep40用滾輪滾動的光標速率
touchbehaviorfalse不要使用,改用emulatetouch
emulatetouchfalse開啟cursor-darg功能(像觸屏滾動的那個效果)
hwaccelerationtruehw是hardware,使用硬件加數功能
boxzoomfalse開啟內容放縮功能
dbclickzoomtrue當boxzoom為true時使用,當鼠標雙擊時zoom為激活狀態
gesturezoomtrue當boxzoom為true、touch devices為true時使用
grabcursorenabledtrue當touchbehavior=true時生效,展示"grab"圖標
autohidemodetrue
"cursor"
false
"leave"
"hidden"
"scroll"
當不滾動時,scrolllbar被隱藏;
僅光標被隱藏;
不隱藏;
僅隱藏上下箭頭;
隱藏;
只有在滾的時候顯示
background""使用css定義background
iframeautoresizetrueauto resize
cursorminheight32設置光標最小高度
preservenatviescrollingtrue使用原始的滾輪
radiloffsetfalse為rail postiont添加top/left的偏移
bouncescrollfalse(only hw accell) enable scroll bouncing at the end of content as mobile-like
spacebarenabledtrueenable page down scrolling when space bar has pressed
railpadding{top: 0, right: 0, left 0, bottom: 0}給rail bar設置padding
disableoutlinetruefor chrome browser, disable outline (orange highlight) when selecting a div with nicescroll
horizrailenabledtruenicescroll can manage horizontal scroll
railalignright垂直滑軌的位置
railvalignbottom水平滑軌的位置
enabletranslate3dtruenicescroll can use css translate to scroll content
enablemousewheeltruenicescroll can manage mouse wheel events
enablekeyboardtruenicescroll can manage keyboard events
smoothscrolltruescroll with ease movement
sensitiverailtrueclick on rail make a scroll
enablemouselockapitruecan use mouse caption lock API (same issue on object dragging)
cursorfixedheightfalse設置光標固定高度
hidecursordelay400set the delay in microseconds to fading out scrollbars
directionlockdeadzone6dead zone in pixels for direction lock activation
nativeparentscrollingtruedetect bottom of content and let parent to scroll, as native scroll does
enablescrollonselectiontrueenable auto-scrolling of content when selection text
cursordragontouch0.3speed of selection when dragged with cursor
oneaxismousemode"auto"horizontal div scrolling starts at left side
scriptpath""drag cursor in touch / touchbehavior mode also
preventmultitouchscrollingtrueit permits horizontal scrolling with mousewheel on horizontal only content, if false (vertical-only) mousewheel don't scroll horizontally, if value is auto detects two-axis mouse
disablemutationobserverfalseforce MutationObserver disabled
enableobservertrueenable DOM changing observer, it tries to resize/hide/show when parent or content div had changed
? ? scrollbarid: false // set a custom ID for nicescroll bars?
scrollbaridfalseset a custom ID for nicescroll bars

總結

以上是生活随笔為你收集整理的NiceScroll文档阅读笔记-NiceScroll(3.7.6)基本使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。