• This repository has been archived on 21/Jan/2021
  • Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    CSS
  • Created almost 12 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This plugin makes it possible to have a fixed position element that is relative to it’s parent. A normal fixed positioned element would be “out of context” and is very difficult to use in the most common situations with fluid designs. This plugin solves that problem with as little code as I could possible get it so it will run in the most optimized way, while also allow you to customize it in many important ways which might suit you best.

stickyfloat

This plugin makes it possible to have a fixed position element that is relative to it’s parent. A normal fixed positioned element would be “out of context” and is very difficult to use in the most common situations with fluid designs. This plugin solves that problem with as little code as I could possible get it so it will run in the most optimized way, while also allow you to customize it in many important ways which might suit you best.

1.2KB - minified + gziped

9KB - uncompressed

Demo page

Benefits

  • Can handle many floated elements, each with it’s own settings
  • Floated elements’ movement can be bound inside their parents’ area
  • Uses Native javascript easing, but using CSS3 transitions would be the optimum (not for IE)
  • Has many settings, such as stick to the bottom or animation style
  • Code is very maintainable and higly efficient
  • Uses requestAnimationFrame with a throttled fall-back

Example – initialize

jQuery('.menu').stickyfloat( {duration: 400} );

Example – update (change settings for a specific element)

jQuery('.menu').stickyfloat('update',{duration : 0, stickToBottom:true });

Example – destroy (no more floating)

jQuery('.menu').stickyfloat('destroy');

Old Browsers (no ES5 support)

Please add this shim before any other script:

<script src='http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.3.0/es5-shim.js'></script>

##Parameters

Setting Default / type what it's for
scrollArea window / DOM element The element which stickyfloat should track it's scroll position (for situations with inner scroll)
duration 200 / Number in ms The duration of the animation in ms
startOffset 0 / Number The amount of scroll offset in px after the animations kicks in
offsetY 0 / Number The offset from the top in px when the object is animated
lockBottom true / Boolean Set to false if you don’t want your floating box to stop at parent's bottom
stickToBottom false / Boolean Make whatever that is “floating” stick to the bottom instead to the top
delay 0 / Number Delay in milliseconds until the animation starts
easing linear / String Easing function (jQuery has only two by default: ‘swing’ & ‘linear’)
cssTransition false / Boolean If you wish to manually set your own CSS3 transition styles on the floated element, set this to 'true'
onReposition undefined / function A callback to be invoked when the floated element is repositioned. Takes one argument: the element.

More Repositories

1

tagify

🔖 lightweight, efficient Tags input component in Vanilla JS / React / Angular / Vue
HTML
3,466
star
2

fancyInput

Makes typing in input fields fun with CSS3 effects
CSS
1,928
star
3

photobox

A lightweight CSS3 image viewer that is pretty to look and and easy to use
JavaScript
747
star
4

fakescroll

vanilla-js lightweight custom HTML scrollbar
JavaScript
363
star
5

knobs

UI knobs controllers for JS/CSS live manipulation of various parameters
JavaScript
305
star
6

pathAnimator

Moves a DOM element along an SVG path (or do whatever along a path...)
HTML
261
star
7

validator

HTML form validation. Perfectly made for all scenerios, lightweight, semantic & easy to use
JavaScript
258
star
8

ui-range

Beautiful UI-Range input component, highly customisable, based on CSS variables. including a floating output value, min & max values on the sides & ticks according to the steps
SCSS
101
star
9

console-colors

Browser Console logs with colors
JavaScript
81
star
10

color-picker

Minimal javascript color picker component
JavaScript
61
star
11

relative-time

javascript function to transform timestamp or date to local relative-time
JavaScript
40
star
12

Do-in

Run tasks repeatedly in a fixed duration
HTML
24
star
13

dragsort

Animated drag sorting for horizontal list items
JavaScript
21
star
14

letterer

breaks a DOM node text into separate letters
HTML
16
star
15

touchy

JavaScript
16
star
16

dateRangePicker

pick a range between dates (months) or from presets
JavaScript
13
star
17

hover-carousel

mouse-position relative carousel
JavaScript
12
star
18

title-tooltip

Automatically converts HTML title attributes to nicer better tooltips
JavaScript
12
star
19

jqSwipe

Minimal swipe special event for touch-enabled devices
JavaScript
11
star
20

simpleGrid

the most performant grid system for same-size items
JavaScript
10
star
21

react-bouncer

Delay rendering of a React component with Debounce, Throttle, or any custom method
9
star
22

infinite

smart endless scrolling
JavaScript
9
star
23

listBreaker

split HTML lists into lists chunks
JavaScript
8
star
24

react-number-input

Renders native number input as a locale number (on blur) and reverts back to a workable number (on focus)
JavaScript
8
star
25

position

Position a DOM element at a certain X,Y or next to another element
JavaScript
6
star
26

react-ref-watcher

Watchable refs changes with conditional re-renders
JavaScript
6
star
27

input_indicator

JavaScript
5
star
28

ui-switch

React Switch component based on native checkbox input, using CSS variables (custom properties) as much as possible. Easily customisable and super lightweight.
JavaScript
4
star
29

react-hooks

React Hooks authored by myself
JavaScript
3
star
30

carouselite

basic, light-weight Carousel jQuery plugin
JavaScript
3
star
31

javascript-interview-questions

javascript interview questions
2
star
32

endless

infinite scrolling jQuery plugin
JavaScript
2
star
33

password-unveil

Unveil password input fields on mouse hover
JavaScript
2
star
34

Mini-page-navigation

lets the user navigate through a web page using a "mini-page" helper on the side of the page, so the user could see where he is in relation to page as a whole, (showing the actual page as a small canvas image)
2
star
35

gulp-file-contents-to-keys

convert files into key/value objects where key is filename, value is the content
JavaScript
2
star
36

translation-yaml-manager

A UI-only system which intends to ease the process of managing YAML translations files across multiple languages
1
star
37

gulp-template-compile-es6

Compile template files to ES6 exported functions
JavaScript
1
star
38

saSlider

Super Awesome Slider - jQuery plugin
CSS
1
star
39

sb-issue-performance-essentials-addon

issue report for Storybook slow rendering
JavaScript
1
star
40

self-descriptive-numbers

Generates self-descriptive numbers
HTML
1
star
41

sb-issue--react-client

Strobook issue #17926
JavaScript
1
star
42

tagify-react-test

Basic React test app for "@yaireo/tagify" package
JavaScript
1
star
43

ToDo

JavaScript
1
star
44

jQuery-ajax-delay

Wrapper for jQuery AJAX method which sets a random delay which simulates real-world latency
JavaScript
1
star
45

multi-range-slider

Custom input element for multiple sliders in one range
JavaScript
1
star
46

swc-js-extension-fails-with-jsx-content

For SWC bug report
JavaScript
1
star