Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var App = {
- init: function() {
- $(".auth .head a").click(function() {
- App.changeContent($(this));
- });
- },
- changeContent: function($dom) {
- var trigger = $dom.data("trigger");
- var $content = this.getContent(trigger);
- $(".auth .content").addClass("hidden"); // Hide all contents
- $content.removeClass("hidden"); // Show wanted content
- $(".auth .head a").removeClass("active");
- $(".auth .head a[data-trigger='"+trigger+"']").addClass("active");
- },
- getContent: function(type) {
- return $(".auth .content[data-type='"+type+"']");
- }
- }
- var OnePage = {
- init: function() {
- // Reset sections
- this.scrollTo(this.getCurrentSection());
- $("body#onePage").bind("mousewheel", function(e){
- if (e.originalEvent.wheelDelta /120 > 0) {
- // Scroll up
- if (OnePage.getPreviousSection()) {
- OnePage.scrollTo(OnePage.getPreviousSection());
- }
- return false;
- } else{
- // Scroll down
- if (OnePage.getNextSection()) {
- OnePage.scrollTo(OnePage.getNextSection());
- }
- return false;
- }
- });
- },
- getCurrentSection: function() {
- return $("section.active");
- },
- getNextSection: function() {
- if (this.isSection(this.getCurrentSection().next())) {
- return this.getCurrentSection().next();
- }
- return false;
- },
- getPreviousSection: function() {
- if (this.isSection(this.getCurrentSection().prev())) {
- return this.getCurrentSection().prev();
- }
- return false;
- },
- isSection: function($dom) {
- return $dom.is("section");
- },
- scrollTo: function($dom) {
- if (!$("html, body").is(":animated")) {
- $("html, body").animate({
- scrollTop: parseInt($dom.position().top)
- }, speed);
- this.getCurrentSection().removeClass("active");
- $dom.addClass("active");
- }
- },
- }
- App.init();
- OnePage.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement