As web developer you must know how to convert your website into fully dynamic web page. Let’s start with our tutorial.
Handle with a column based layout can be a horror dream, especially in the age of responsive design and the forsaking of
<table> tags used in layouts. Today, I’ve sure to tackle this complication, and have organized a plugin that will let you evolve a fully dynamic, full page, column based exploration using just one JS call and minimal HTML markups.
This plugin is splendid for when you want a simple music page that repeats your photography or typography. Without further ado, let’s dive into the approach of this plugin and how you can use it.
How does this work?
I have always necessary a plugin that will knob the work of division and comparison of the create relative to the browser’s width. This plugin will do just that. Essentially, the plugin will resolve each container’s width by capturing the parameter “columns” defined by the user and break a hundred by it, and the item will use this percentage as a width. Now, this is where it receive trickily. The column will widen according to the parameter
hover_size when the user hovers over a column, display the interactivity between the user and the customer interface.
The complication is that when one column bolster, the other list will have to move out of the way and constantly out of the viewport which could spawn a usability problem. To overcome this, I had to calculator each column’s width and area every time the user’s cursor enters and needle the area. This grant the layout to always prepare for the communication and be in the viewport at any time.
Another problem I detect is that when rousing the expansion of the column’s width, it may origin a layout lambent when the rousing width couldn’t catch up with the cursor, prompt
mouseenter all over again. I fixed this by drape the content of each column with a cover and instead of stimulating the column itself (where
mouseleave is being bound), the plugin will bolster the width of the column away and animate the wrapper central instead so that it doesn’t origin any flickering.
To use this plugin, make sure you’ve involved the latest jQuery plugin available here, and the jquery.fullpagenav.js and fullpagenav.css which can be found here, into your document’s <head>. With essentially all my plugins, we start off with a minimal HTML markup and one JS call as seen below:
The <img> tag will be used as a background and widen when the object is clicked. Easily remove this if you do not wish a background image. You can also use a disparate tag if you wish, Despite you will use to supply a new sector option. More info on that below.
- columns: You can represent how many list you want the plugin to break and arrange inside a prospect port. It is suggested that this number is analogous to the number of <li> tags in the markup, but not mandatory. You can have more <li> tags than the column defined here. The plugin will put the waste columns out of the viewport and let you scroll horizontally. The default value is 5.
- selector: As mentioned earlier, you can switch the tag used from a list to whatever you like, but make clear you define your custom selector here. This option welcome a CSS selector. The default value is “> li”.
- hover_size: This option will be used as a bolster width of the longer column to show the attractive between the user and the consolidated. The option accepts a percentage value. The default value is “30%”.
- animateDuration: You can set the acceleration of the animation here. This extent will be used universally throughout the plugin. This option welcomes milliseconds without the unit. and the default value is 500.
- animateFrom: This option lets you construct which direction the expansion will occur to the hovered column. Decent values are “left”, “right” and “auto”. For “auto”, the plugin will accordingly determine the direction from which side the cursor enters the column. The default value is “left”.
- clickable: You can change the ability to make each column clickable by toggling this option to “true”. Make clear you add an additional data-link attribute to the li tag which holds the URL. The default value is “true”. You can detect an example below.
- afterClicked: This is a callback function that will be performed after the user clicks the column. This is splendid for when you need to populate the page with an Ajax instead of a conventional page load.
How to make the column clickable
As affirmed, here’s an illustration on how to make each column clickable. First, make clear your markups are as follows:
And all you have to do is knob the clickable option to “true” and the peripheral will handle all for you.