Giter Site home page Giter Site logo

lenconda / fixit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itsprakash87/fixit

0.0 2.0 0.0 11 KB

Fixit is a jquery plugin which can be used to fix any element on the webpage.

Home Page: https://www.npmjs.com/package/fix-it

License: MIT License

JavaScript 100.00%

fixit's Introduction

Fixit

Fixit is a jquery plugin which can be used to fix any element on the webpage. For Demo : Click here

Fixit :

Fixit jquery plugin can be used to fix the element at a certain position when the webpage is scrolled and the element is to be hidden, so that the element stay visible on the webpage. By passing the values of the different options provided, one can control the element. This easy to use plugin prevent one from dealing with the jquery/javascript code.

Install :

npm install fix-it

How to use

  • Include jQuery and fixit.
<script src="jquery.js"></script>
<script src="jquery.fixit.js"></script>
  • Give an ID to the target element.(Always give an unique id to target element.)
<div id = "fixthis"> Content to be fixed. </div>
  • Add class to style the element if you want. (Avoid inline style and style by id for target element.)
<div id = "fixthis" class = "myClass" > Content to be fixed. </div>
  • Call fixit.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit();
  });
</script>
  • You are done.

Options

Following are the different options which can be passed to the function to control the target element.

  • topMargin: (default: 0) Margin in pixels between the page top and the element's top when it is fixed.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit({topMargin:10});
  });
</script>
  • addClassAfter: (default: 'null') Name of the class which will be added to the element when "fixed". This class will be removed when the element is "unfixed".
<script>
  $(document).ready(function(){
    $("#fixthis").fixit({topMargin:10, addClassAfter:"classToAdd"});
  });
</script>
  • sameDimension: (default: 'true') Boolean value determining if the dimension of the element should be same after it is fixed. If any class name is passed, the values of width and height in the class will be ignored, if 'true'.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit({topMargin:10, addClassAfter:"classToAdd", sameDimension:true});
  });
</script>
  • zIndex: (default: 0) z-index value of the target element after it is fixed.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit({topMargin:10, addClassAfter:"classToAdd", sameDimension:true, zIndex : 50});
  });
</script>

Events

Following are the custom events which are triggered.

  • fixed: When the element get fixed.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit();
    $("#fixthis").on("fixed",function(){
		  // 	Things to do....
	  });
  });
</script>
  • unfixed: When the element is back to its original location.
<script>
  $(document).ready(function(){
    $("#fixthis").fixit();
    $("#fixthis").on("unfixed",function(){
		  // 	Things to do....
	  });
  });
</script>

fixit's People

Contributors

itsprakash87 avatar mskayali avatar

Watchers

James Cloos avatar Peng Hanlin 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.