GithubHelp home page GithubHelp logo

sade / jquery.hookto Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 360 KB

Move an HTML element on breakpoint screen size with dynamic back-in-place.

Home Page: https://sade.github.io/jquery.hookTo/

JavaScript 100.00%
jquery plugin hooking hook hooks placement breakpoint html-element callback-methods move

jquery.hookto's Introduction

jQuery.HookTo

Hook To - jQuery plugin

Move an HTML element on specific screen size with dynamic back-in-place. hookto demo Example here : hookto codepen

Install

NPM

Install jQuery first, then run : npm install jquery.hookto

Manualy

Install jQuery first, then jquery.hookto :

<script src="jquery.min.js"></script>
<script src="jquery.hookto.js"></script>

How to

  • Add data-hook-to="" attribute to your element.
  • Create HTML a traget.

Example :

<div class="my-element-to-move" 
     data-hook-to="#link-to-target">
</div>
<div class="toto">
    <meta id="target"/>
</div>

In this case, my HTML element class="my-element-to-move" will be insert just after the HTML element <meta id="target">.

Settings

HTML attributes method

<div 
  data-hook-to-mobile-first="true"
  data-hook-to="#hook-destination" 
  data-hook-to-position="after" 
  data-hook-to-return="768"
  data-hook-to-origin-prefix="hookto-orig"></div>

jQuery method

You can overwrite default values with javascript :

$('.my-element').hookTo(destinationHook, options);
var options = {
  'hookOriginPrefix': 'hookto-orig',
  'position': 'after',
  'returnAt': '768',
  'mobileFirst': true
}

Callback methods

In jQuery, you can add some actions using this callbacks methods.

$('.my-element').hookTo(destinationHook, {
   'onInit': function () {},
   'onHook': function () {},
   'onUnhook': function () {}
});

All attributes

Propriety Type Default Description
data-hook-to-mobile-first Boolean true The element will be move if screen size is > of the breakpoint. ( false, < of the breakpoint )
data-hook-to HTML element - An HTML element. Put # if is an ID, . if is a class.
data-hook-to-position String after Put the element just after. ( you can use "before", or "inside" instead)
data-hook-to-return Number 768 Breakpoint. Move the element only after with window size
data-hook-to-origin-prefix String hookto-orig Breakpoint. Move the element only after with window size.

jquery.hookto's People

Contributors

ao-abaron avatar fantomtracks avatar sade avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jquery.hookto's Issues

Add in documentation

Hi,
Don't forget to add this in your documentation for an use on class.

$('.elementsByClassToHook').each(function(i,item){ $(this).hookTo('#hook', {'returnAt': breakpoint}); });

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.