UNPKG

uikit

Version:

UIkit is a lightweight and modular front-end framework for developing fast and powerful web interfaces.

126 lines (98 loc) 2.87 kB
// Name: Slider // Description: Component to create horizontal sliders // // Component: `uk-slider` // // Sub-objects: `uk-slider-container` // `uk-slider-items` // // States: `uk-active` // // ======================================================================== // Variables // ======================================================================== @slider-container-margin-left: -25px; @slider-container-margin-right: @slider-container-margin-left; /* ======================================================================== Component: Slider ========================================================================== */ /* * 1. Prevent tab highlighting on iOS. */ .uk-slider { /* 1 */ -webkit-tap-highlight-color: transparent; .hook-slider(); } /* Container ========================================================================== */ /* * 1. Fallback for Safari 15 and older * 2. Clip child elements * `clip` prevents accidental scrolling through elements in slide getting focused * `clip` also works in only one direction */ .uk-slider-container { /* 1 */ overflow-x: hidden; /* 2 */ overflow-x: clip; } /* * Widen container to prevent box-shadows from clipping, `large-box-shadow` */ .uk-slider-container-offset { margin-left: @slider-container-margin-left; margin-right: @slider-container-margin-right; padding-left: -@slider-container-margin-left; padding-right: -@slider-container-margin-right; } /* Items ========================================================================== */ /* * 1. Optimize animation * 2. Create a containing block. In Safari it's neither created by `transform` nor `will-change`. * 3. Disable horizontal panning gestures */ .uk-slider-items { /* 1 */ will-change: transform; /* 2 */ position: relative; /* 3 */ touch-action: pan-y; } /* * 1. Reset list style without interfering with grid * 2. Prevent displaying the callout information on iOS. */ .uk-slider-items:not(.uk-grid) { display: flex; /* 1 */ margin: 0; padding: 0; list-style: none; /* 2 */ -webkit-touch-callout: none; } .uk-slider-items.uk-grid { flex-wrap: nowrap; } /* Item ========================================================================== */ /* * 1. Let items take content dimensions (0 0 auto) * `max-width` needed to keep image responsiveness and prevent content overflow * 2. Create position context */ .uk-slider-items > * { /* 1 */ flex: none !important; box-sizing: border-box; max-width: 100%; /* 2 */ position: relative; } // Hooks // ======================================================================== .hook-slider-misc(); .hook-slider() {} .hook-slider-misc() {}