Vue Horizontal is to design your web application for a horizontal experience which can be boring and cumbersome if you are new to web development. Whereas vertical design comes naturally whereas HTML is naturally vertical by the view of the design: block. With Display: flex, aligning content horizontally becomes natural and intuitive but does not support flow or navigation. You start adding more hacks and tricks to get the layout you want, but these hacks aren’t consistent and have been SSG or cross-browser SEO tested. You found the idea.
There are many libraries already in the open-source world, some using DOM manipulation directly, others importing JavaScript or another old JQuery library. You do not want that. Vue already does that. This is the original Vue built for Vue, and Vue is the only peer dependency required. All display modes (SPA / SSR / SSG) are supported and tested with E2E tools.
horizontal scroll example, horizontal scrolling website, horizontal scrolling div with arrows, horizontal scroll website template, horizontal scrolling website html
Features
- SSR / SSG / SPA: Support all rendering modes
- Mobile-first for responsive web
- Customizable navigation: slider, buttons, or basically everything
- Focus on UX, smooth scrolling, capture for a variety of use cases.
- Small size 3KB for CDN users
- Highly expandable for any use case with well-documented recipes.
- You can control how your content is organized with HTML
- You can control its appearance using CSS
- You can control how the layout is navigated with Vue.js
How to make use of it:
Install and download:
# Yarn $ yarn add vue-horizontal # NPM $ npm i vue-horizontal
1. Import and register the component.
import VueHorizontal from 'vue-horizontal';
export default { components: {VueHorizontal} } // or Vue.use(VueHorizontal);
2. Add the <vue-horizontal> component to the template.
<vue-horizontal> </vue-horizontal>
3. Add slidesĀ to the scroller.
<vue-horizontal> <div class="item"> <h3>Item 1</h3> <p>As you can see these are just html elements.</p> </div> <section> <h4>Item 2</h4> </section> <section> <h3>Item 3</h3> </section> <section v-for="item in items" :key="item.i"> <h3>{{ item.title }}</h3> <p>{{ item.content }}</p> </section> <section> <h3>Last Item</h3> </section> </vue-horizontal>
export default { data() { return { items: [...Array(5).keys()].map((i) => { return {i, title: `v-for: ${i}`, content: `š Paragraph ${i}`}; }), } } }
4. Component props available.
button: { type: Boolean, default: () => true, }, buttonBetween: { type: Boolean, default: () => true }, scroll: { type: Boolean, default: () => false, }, responsive: { type: Boolean, default: () => false, }, /** * Move window, indicates the percent of width to travel when nav is triggered. */ displacement: { type: Number, default: () => 1.0 }, /** * Snap to start|center|end */ snap: { type: String, default: () => 'start', },
5. API methods.
// prev item $refs.horizontal.prev(); // next item $refs.horizontal.next(); // scroll to an item $refs.horizontal.scrollToIndex(index); // scroll to left $refs.horizontal.scrollToLeft(index); // refresh the scroller $refs.horizontal.refresh();
6. Events.
onPrev() { this.prev += '- clicked prev' }, onNext() { this.next += '- clicked next' } nScroll(data) { this.scroll = data }, onScrollDebounce(data) { this.scrollDebounce = data }
Horizontal Scroller Layout For Vue, Vue Horizontal Plugin/Github, horizontal scroll test, website horizontal scroll problem
See Demo And Download
Official Website(fuxingloh): Click Here
This superior jQuery/javascript plugin is developed by fuxingloh. For extra Advanced Usages, please go to the official website.