Более 70 плагинов jquery скроллинга для вашего сайта

Custom Scrollbar Example

Note: The -webkit-scrollbar is not supported by Firefox or IE and Edge.


Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

Lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum

More

Fullscreen VideoModal BoxesDelete ModalTimelineScroll IndicatorProgress BarsSkill BarRange SlidersTooltipsDisplay Element HoverPopupsCollapsibleCalendarHTML IncludesTo Do ListLoadersStar RatingUser RatingOverlay EffectContact ChipsCardsFlip CardProfile CardProduct CardAlertsCalloutNotesLabelsCirclesStyle HRCouponList GroupList Without BulletsResponsive TextCutout TextGlowing TextFixed FooterSticky ElementEqual HeightClearfixResponsive FloatsSnackbarFullscreen WindowScroll DrawingSmooth ScrollGradient Bg ScrollSticky HeaderShrink Header on ScrollPricing TableParallaxAspect RatioResponsive IframesToggle Like/DislikeToggle Hide/ShowToggle Dark ModeToggle TextToggle ClassAdd ClassRemove ClassActive ClassTree ViewRemove PropertyOffline DetectionFind Hidden ElementRedirect WebpageZoom HoverFlip BoxCenter VerticallyCenter Button in DIVTransition on HoverArrowsShapesDownload LinkFull Height ElementBrowser WindowCustom ScrollbarHide ScrollbarDevice LookContenteditable BorderPlaceholder ColorText Selection ColorBullet ColorVertical LineDividersAnimate IconsCountdown TimerTypewriterComing Soon PageChat MessagesPopup Chat WindowSplit ScreenTestimonialsSection CounterQuotes SlideshowClosable List ItemsTypical Device BreakpointsDraggable HTML ElementJS Media QueriesSyntax HighlighterJS AnimationsGet Iframe Elements

Change Logs:

v3.1.5 (2016-07-11)

update

v3.1.3 (2015-11-18)

fixed issue regarding cross-domain iframes

v3.1.0 (2015-10-06)

fixed for mobile chrome.

v3.0.8 (2015-03-10)

update


v3.0.7 (2014-12-30)

update

v3.0.6 (2014-11-29)

update

v3.0.5 (2014-10-21)

update

v3.0.4 (2014-09-06)

update

v3.0.3 (2014-08-01)

Fixed minor issue with RequireJS in jquery.mCustomScrollbar.concat.min.js and removed version from CSS.

v3.0.3 (2014-07-29)

update.

v3.0.2 (2014-05-31)

update.

v3.0.0 (2014-05-22)

  • update.
  • css bugfix

v2.8.7 (2014-05-19)

update.

v2.8.6 (2014-05-14)

update.

v2.8.5 (2014-05-08)

update.

  • Prev: Smooth Sliding Notification Bar Plugin — msgTips
  • Next: Automatically Geocode And Display A Location — auto-geocoder

Changelog:

v5.0.6 (11/07/2019)

Fix a case where flexbox display could not work properly

v5.0.2 (10/19/2019)

Fix a case where flexbox display could not work properly

v4.1.0 (07/03/2019)

  • Fix a case where flexbox display could not work properly
  • Fix scrollbar width detection calculation being wrong in some zoom levels

v4.0 (05/21/2019)

  • Add “dragging” class when scrollbar is dragged
  • Avoid unnecessary array copies for NodeList iteration
  • Bugfixes

01/17/2019

fix: remove missing DOM listeners on unmount

01/14/2019


fix: fix vue plugin tests not passing

11/19/2018

fix: capture pointer events instead of bubbling

11/14/2018

Fix ‘visible’ classname bug when using custom classnames

11/02/2018

fix wrong scrollbar position calculation when track has padding

10/16/2018

Add ‘visible’, ‘horizontal’ and ‘vertical’ classnames to options

08/19/2018

Fix handle not being draggable on IE/Edge

08/10/2018

Fix horizontal scrollbar missing same logic as vertical one

08/01/2018

Force the scrollbar to be displayed when hovered;

v3.0.0beta (07/15/2018)

Update

Installation

npm i react-custom-scroll --save
  • Same design on all browsers
  • Scrollbar is above the content instead of floating to the side — same layout on scrolled content as not scrolled content

Custom scroll component is available in commonJS format so you can just require it after installing. There is also a UMD version — inside dist directory. In both cases you have to include the customScroll.css file in your page. It is located in /dist directoryFrom unpkg cdn:

Wrap your content with the custom scroll component Remove any overflow style properties from your content root component — The custom scroll will take care of it

importCustomScrollfrom'react-custom-scroll';
<CustomScroll>  your content</CustomScroll>

Your own custom design can be applied by styling these 2 classes in your css:

  • rcs-custom-scrollbar — this class styles the container of the scroll handle, you can use it if your handle width is greater than the default.
  • rcs-inner-handle — this class styles the handle itself, you can use it to change the color, background, border and such of the handle

You can see a usage example in example/firstComp/firstComp.scss

  • allowOuterScroll : boolean, default false. Blocks outer scroll while scrolling the content
  • heightRelativeToParent : string, default undefined. Content height limit is relative to parent — the value should be the height limit.
  • flex : number, default undefined. If present will apply to the content wrapped by the custom scroll. This prop represents flex size. It is only relevant if the parent of customScroll has display: flex. See example below. This prop will override any value given to heightRelativeToParent when setting the height of customScroll.
  • onScroll — function, default undefined. Listener that will be called on each scroll.
  • addScrolledClass : boolean, default false. If true, will add a css class ‘content-scrolled’ while being scrolled.
  • freezePosition : boolean, default false. When true, will prevent scrolling.
  • minScrollHandleHeight : number, sets the mimimum height of the scroll handle. Default is 38, as in Chrome on OSX.
  • rtl : boolean, default false. Right to left document, will place the custom scrollbar on the left side of the content, and assume the native one is also there.
  • scrollTo: number, default undefined. Will scroll content to the given value.
<CustomScrollheightRelativeToParent="calc(100% - 20px)">  your content</CustomScroll>
  • Check if you forgot to remove ‘overflow’ properties from the content root element.
  • If you’re using JSX, make sure you use Pascal case and not camelCase <CustomScroll> and not <customScroll>. starting with lower case causes JSX to treat the tag as a native dom element
  • Make sure you have a height limit on the content root element (max-height)
  • Check if your height limit is relative to parent, and you didn’t use heightRelativeToParent prop.

There are some details that apply when using customScroll on elements with size set by css flex. Here is an example for an HTML structure before using customScroll:

<SomeParentstyle="display: flex; height: 500px;"><FixedHeightElementstyle="height: 100px"><FixedHeightElement/><FlexibleHeightElementstyle="flex:1; overflow:scroll">    your content(with enough height to cause a scroll)<FlexibleHeightElement/></SomeParent>

In this example, a scroll is active on the flexibleHeightElement, where the flex size sets it’s height to 400px, after the fixedHeight element took 100px.

There are 2 options to use customScroll with this structure:

Wrapping the content: For this solution, the overflow property should be removed from the flex size element, since the customScroll will take care of that. Instead, min-height and min-width should be set to 0.

<someParentstyle="display: flex; height: 500px;"><fixedHeightElementstyle="height: 100px"><fixedHeightElement/><flexibleHeightElementstyle="flex:1; min-height: 0; min-width: 0"><CustomScrollheightRelativeToParent="100%">      your content(with enough height to cause a scroll)<CustomScroll/><flexibleHeightElement/></someParent>

Replacing the flex-size element with customScroll

<someParentstyle="display: flex; height: 500px;"><fixedHeightElementstyle="height: 100px"><fixedHeightElement/><CustomScrollflex="1">      your content(with enough height to cause a scroll)<CustomScroll/></someParent>

To build the project in watch mode, run ‘npm run develop’ or ‘yarn develop’. For production build — run yarn build .

npm installnpm testnpx karma start

How to use it:

Load the required ‘smooth-scrollbar.css’ and ‘smooth-scrollbar.js’ in the html page.

<link href="dist/smooth-scrollbar.css" rel="stylesheet">
<script src="dist/smooth-scrollbar.js"></script>

Create a scrollable area as follows:

<section scrollbar>
  Scrollable content goes here
</section>

<!-- Or -->
<section data-scrollbar>
  Scrollable content goes here
</section>

<!-- Or -->
<scrollbar>
  Scrollable content goes here
</scrollbar>

Make it scrollable when the inner content is larger than its parent container.

section {
  width: 500px;
  height: 300px;
  overflow: auto;
}

Append a custom scrollbar to the scrollable area.

Scrollbar.initAll();

Possible options with default values.

Scrollbar.initAll({

  // Momentum reduction damping factor, a float value between (0, 1)
  damping: .1

  // Minimal size for scrollbar thumb.
  thumbMinSize: 20,

  // Render scrolling by integer pixels
  renderByPixels: true,

  // Whether allow upper scrollable content to continue scrolling when current scrollbar reaches edge. 
  // When set to 'auto', it will be enabled on nested scrollbars, and disabled on first-class scrollbars.
  continuousScrolling: 'auto',

  // Keep scrollbar tracks always visible.
  alwaysShowTracks: false,

  // Element to be used as a listener for mouse wheel scroll events. 
  // By default, the container element is used.
  wheelEventTarget: null,

  // plugins
  plugins: {}
  
});

API methods.

// Init scrollbar on given element, and returns scrollbar instance
Scrollbar.init( element,  )

// Automatically init scrollbar on all elements refer to selector scrollbar, , , returns an array of scrollbars collection:
Scrollbar.initAll(  )

// Check if scrollbar exists on given element:
Scrollbar.has( element )

// Get scrollbar on the given element, if no scrollbar instance exsits, return undefined:
Scrollbar.get( element )

// Return an array that contains all scrollbar instances:
Scrollbar.getAll()

// Remove scrollbar on the given element, same as scrollbar#destroy() method.
Scrollbar.destroy( element )

// Remove all scrollbar instances.
Scrollbar.destroyAll()

// Attaches plugins to scrollbars.
Scrollbar.use()

// Attaches default style sheets to current document. 
Scrollbar.attachStyle()

// Removes default styles from current document. 
Scrollbar.detachStyle()

Прокручивание большого содержания

Есть ошибка в  jquery.min.js, которая сбрасывает значение в 0 при анимации значения больше, чем 9999 px. Данная ошибка влияет на панель прокрутки, если высота или ширина содержания равна или больше 10000 px, что приводит к рывкам при прокрутке. Это известная ошибка, которая будет исправлена в следующих версиях библиотеки. Но сейчас придётся использовать временное решение. Так как редактирование jquery.min.js является плохой идеей, мы просто изменим функцию, которая содержит код с ошибкой.

Нужно вставить следующий код в функцию загрузки окна:

/* Функция для обхода ошибки с 10000 px для jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem != null && (!this.elem.style || this.elem.style == null) ) {
      return this.elem;
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}

CSS Custom Scrollbar Source Code


Before sharing source code, let’s talk about it. First I have created a div with 3500px width, because of creating a scroll. This effect will run on WebKit browsers like Chrome, Safari, Opera. There is a CSS property to customize the scroll bar (get info). I have put 30px width of the scrollbar using this property.

After that, we have another two properties and . Scrollbar-thumb is for the element which moves on the scroll, we also can drag it up or down. Scrollbar-track is for the whole bar section, you can call this scrollbar’s background.

I have just given styles in these two elements in CSS. After getting the codes you will understand what are the styles I have placed. To creating this program you have to create only 2 files. One for HTML & one for CSS. Follow these steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given here below.

index.html

XHTML

<!DOCTYPE html> <!— code by webdevtrick ( https://webdevtrick.com ) —> <html lang=»en» >

<head> <meta charset=»utf-8″> <title>CSS Custom Scrollbar | Webdevtrick.com</title> <link rel=»stylesheet» href=»style.css»> </head> <body>

<h1> CUSTOM CSS SCROLLBAR</h1>

</body> </html>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

<!DOCTYPE html> <!— code by webdevtrick ( https://webdevtrick.com ) —>

<html lang=»en» >

  <head>

<meta charset=»UTF-8″>

<title>CSS Custom Scrollbar | Webdevtrick.com</title>

<link rel=»stylesheet»href=»style.css»>

</head> <body>  

<h1> CUSTOM CSS SCROLLBAR</h1>

  </body> </html>

style.css

Now create a CSS file named ‘style.css‘ and put these codes.

style.css

CSS

/** code by webdevtrick ( https://webdevtrick.com ) **/ ::-webkit-scrollbar { width: 30px; }

::-webkit-scrollbar-thumb { border-radius: 30px; background: -webkit-gradient(linear,left top,left bottom,from(#ff8a00),to(#da1b60)); box-shadow: inset 2px 2px 2px rgba(255,255,255,.25), inset -2px -2px 2px rgba(0,0,0,.25);}

::-webkit-scrollbar-track { background-color: #fff; background: linear-gradient(to right,#201c29,#201c29 1px,#100e17 1px,#100e17); } body { margin: 0px; padding: 0px; background-color: #333; height: 3500px; width: 100%; }

h1 { position: absolute; top: 50%; left: 49%; transform: translate(-50%, -50%); color: white; font-family: arial; font-size: 55px; padding: 7px; border: 5px solid #FF484B; border-radius: 20px; }

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

/** code by webdevtrick ( https://webdevtrick.com ) **/

::-webkit-scrollbar {

width30px;

}  

::-webkit-scrollbar-thumb {

border-radius30px;

background-webkit-gradient(linear,lefttop,leftbottom,from(#ff8a00),to(#da1b60));

box-shadowinset2px2px2pxrgba(255,255,255,.25),inset-2px-2px2pxrgba(0,0,0,.25);}

::-webkit-scrollbar-track {

background-color#fff;

backgroundlinear-gradient(toright,#201c29,#201c291px,#100e171px,#100e17);

}

body {

margin0px;

padding0px;

background-color#333;

height3500px;

width100%;

}

h1 {

positionabsolute;

top50%;

left49%;

transformtranslate(-50%,-50%);

colorwhite;

font-familyarial;

font-size55px;

padding7px;

border5pxsolid#FF484B;

border-radius20px;

}

That’s It. Now you have successfully created CSS Custom Scrollbar With Modification, A Scrollbar Style Customize With CSS. If you have any question or doubt comment down below.

Thanks For Visiting, Keep Visiting.

How to use it:

Install the minibar via package managers.

# NPM
$ npm install minibarjs

# Bower
$ bower install minibarjs

Import the minibarjs into your project or directly include the JavaScript and CSS files on the webpage.

<link rel="stylesheet" href="minibar.min.css">
<script src="minibar.min.js"></script>

Initialize the MiniBarjs on the target container.

new MiniBar('#myContent');

Style the custom scrollbar in the CSS.

.mb-track { border-radius: 5px; }

.mb-bar { background-color: #4C9689; }

body > .mb-container > .mb-track {
  background-color: #110c10;
  border-radius: 5px;
}

Default configuration properties.

new MiniBar('#myContent',{

    // or progress
    barType: "default",

    // min size
    minBarSize: 10,

    // always shows scrollbars
    alwaysShowBars: false,

    // enables horizontal/vertical scrollbars
    scrollX: true,
    scrollY: true,

    // shows nav buttons
    navButtons: false,

    // scroll amount in pixels
    scrollAmount: 10,
    
    // MutationObserver API
    mutationObserver: {
      attributes: false,
      childList: true,
      subtree: true
    },

    // default classes
    classes: {
      container: "mb-container",
      content: "mb-content",
      track: "mb-track",
      bar: "mb-bar",
      visible: "mb-visible",
      progress: "mb-progress",
      hover: "mb-hover",
      scrolling: "mb-scrolling",
      textarea: "mb-textarea",
      wrapper: "mb-wrapper",
      nav: "mb-nav",
      btn: "mb-button",
      btns: "mb-buttons",
      increase: "mb-increase",
      decrease: "mb-decrease",
      item: "mb-item",
      itemVisible: "mb-item-visible",
      itemPartial: "mb-item-partial",
      itemHidden: "mb-item-hidden"
    }

});

Callback functions.

new MiniBar('#myContent',{

    onInit: function() {},
    onUpdate: function() {},
    onStart: function() {},
    onScroll: function() {},
    onEnd: function() {},

});

API methods.

// scrolls to a specific point
instance.scrollTo(position, axis);

// scrolls the content by a certain amount
instance.scrollBy(amount, axis, duration, easing);

// recalculates scollbar sizes and positions
instance.update();

// destroys the scrollbar
instance.destroy();

Terminologies

consists of seven different pseudo-elements, and together comprise a full scrollbar UI element:

  1. the background of the bar itself.
  2. the directional buttons on the scrollbar.
  3. the empty space “below” the progress bar.
  4. the top-most layer of the the progress bar not covered by the thumb.
  5. the draggable scrolling element resizes depending on the size of the scrollable element.
  6. the bottom corner of the scrollable element, where two scrollbar meet.
  7. the draggable resizing handle that appears above the scrollbar-corner at the bottom corner of some elements.

Now that you are familiar with the terminologies, let’s start!


С этим читают