Code Monkey home page Code Monkey logo

autofix_anything's Introduction

#Auto Fix Anything by Pete R. This little plugin will let you automatically fix position of any container on your website with one JS call Created by Pete R., Founder of BucketListly

Auto Fix Anything

Demo

View demo

Compatibility

Modern browsers such as Chrome, Firefox, and Safari, on desktop have been tested.

Basic Usage

With this plugin you can dynamically fix a container within the viewport with one JS call. The plugin will detect when to fix/unfix the position automatically.

To add this to your website, simply include the latest jQuery library together with jquery.autofix_anything.js and autofix_anything.css into your document's <head> and call the function as follows:

$(".sidebar").autofix_anything({
  customOffset: false, // You can define custom offset for when you want the container to be fixed. This option takes the number of pixels from the top of the page. The default value is false which the plugin will automatically fix the container when the it is in the viewport
  manual: false, // Toggle this to true if you wish to manually fix containers with the public method. Default value is false
  onlyInContainer: true // Set this to false if you don't want the fixed container to limit itself to the parent's container.
});

Although, the HTML and CSS structures below are not mandatory, following it will help the plugin perform better out of the box

<div class="wrapper">
  ..
  <div class="sidebar">..</div>
  ..
</div>
.wrapper {
  position: relative;
}

Public Method

You can also fix your containers programmatically as well:

$.fn.manualfix()

This method will let you toggle the fix state of the container. The method will detect whether to fix or not to fix based on the current state.

Note: Make sure the manual option of the main function call is toggled to true.

$(".sidebar").autofix_anything({
  manual: true
});

and call this function anywhere you like to toggle it.

$(".sidebar").manualfix()

If you want to see more of my plugins, visit The Pete Design, or follow me on Twitter and Github.

Other Resources

autofix_anything's People

Contributors

peachananr avatar

Watchers

 avatar  avatar

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.