fullpage.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. /**
  2. * fullPage 1.5.3
  3. * https://github.com/alvarotrigo/fullPage.js
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2013 alvarotrigo.com - A project by Alvaro Trigo
  7. */
  8. (function (b) {
  9. b.fn.fullpage = function (c) {
  10. function m(a) {
  11. if (c.autoScrolling) {
  12. a = window.event || a;
  13. a = Math.max(-1, Math.min(1, a.wheelDelta || -a.detail));
  14. var e;
  15. e = b(".section.active");
  16. if (!k)
  17. if (e = e.find(".slides").length ? e.find(".slide.active").find(".scrollable") : e.find(
  18. ".scrollable"), 0 > a)
  19. if (0 < e.length)
  20. if (v("bottom", e)) b.fn.fullpage.moveSectionDown();
  21. else return !0;
  22. else b.fn.fullpage.moveSectionDown();
  23. else if (0 < e.length)
  24. if (v("top", e)) b.fn.fullpage.moveSectionUp();
  25. else return !0;
  26. else b.fn.fullpage.moveSectionUp();
  27. return !1
  28. }
  29. }
  30. function F() {
  31. document.addEventListener ? (document.addEventListener("mousewheel", m, !1), document.addEventListener(
  32. "DOMMouseScroll", m, !1)) : document.attachEvent("onmousewheel", m)
  33. }
  34. function n(a, e) {
  35. var d = {},
  36. f, h = a.position(),
  37. h = null !== h ? h.top : null,
  38. H = G(a),
  39. l = a.data("anchor"),
  40. g = a.index(".section"),
  41. p = a.find(".slide.active");
  42. if (p.length) {
  43. f = p.data("anchor");
  44. var q = p.index()
  45. }
  46. p = b(".section.active").index(".section") + 1;
  47. a.addClass("active").siblings().removeClass("active");
  48. k = !0;
  49. "undefined" !== typeof l ? I(q, f,
  50. l) : location.hash = "";
  51. c.autoScrolling ? (d.top = -h, f = "#superContainer") : (d.scrollTop = h, f = "html, body");
  52. c.css3 && c.autoScrolling ? (b.isFunction(c.onLeave) && c.onLeave.call(this, p, H), z(
  53. "translate3d(0px, -" + h + "px, 0px)", !0), setTimeout(function () {
  54. b.isFunction(c.afterLoad) && c.afterLoad.call(this, l, g + 1);
  55. setTimeout(function () {
  56. k = !1;
  57. b.isFunction(e) && e.call(this)
  58. }, J)
  59. }, c.scrollingSpeed)) : (b.isFunction(c.onLeave) && c.onLeave.call(this, p, H), b(f).animate(d,
  60. c.scrollingSpeed, c.easing,
  61. function () {
  62. b.isFunction(c.afterLoad) &&
  63. c.afterLoad.call(this, l, g + 1);
  64. setTimeout(function () {
  65. k = !1;
  66. b.isFunction(e) && e.call(this)
  67. }, J)
  68. }));
  69. r = l;
  70. c.autoScrolling && (K(l), L(l, g))
  71. }
  72. function u(a, e) {
  73. var d = e.position(),
  74. f = a.find(".slidesContainer").parent(),
  75. h = e.index(),
  76. g = a.closest(".section"),
  77. l = g.index(".section"),
  78. k = g.data("anchor"),
  79. p = g.find(".fullPage-slidesNav"),
  80. q = e.data("anchor");
  81. if (c.onSlideLeave) {
  82. var m = g.find(".slide.active").index(),
  83. n;
  84. n = m > h ? "left" : "right";
  85. b.isFunction(c.onSlideLeave) && c.onSlideLeave.call(this, k, l + 1, m, n)
  86. }
  87. e.addClass("active").siblings().removeClass("active");
  88. "undefined" === typeof q && (q = h);
  89. g.hasClass("active") && (c.loopHorizontal || (g.find(".controlArrow.prev").toggle(0 != h), g.find(
  90. ".controlArrow.next").toggle(!e.is(":last-child"))), I(h, q, k));
  91. c.css3 ? (d = "translate3d(-" + d.left + "px, 0px, 0px)", a.find(".slidesContainer").addClass(
  92. "easing").css({
  93. "-webkit-transform": d,
  94. "-moz-transform": d,
  95. "-ms-transform": d,
  96. transform: d
  97. }), setTimeout(function () {
  98. b.isFunction(c.afterSlideLoad) && c.afterSlideLoad.call(this, k, l + 1, q, h);
  99. s = !1
  100. }, c.scrollingSpeed)) : f.animate({
  101. scrollLeft: d.left
  102. },
  103. c.scrollingSpeed,
  104. function () {
  105. b.isFunction(c.afterSlideLoad) && c.afterSlideLoad.call(this, k, l + 1, q, h);
  106. s = !1
  107. });
  108. p.find(".active").removeClass("active");
  109. p.find("li").eq(h).find("a").addClass("active")
  110. }
  111. function M() {
  112. var a = b(window).width();
  113. g = b(window).height();
  114. c.resize && S(g, a);
  115. b(".section").each(function () {
  116. parseInt(b(this).css("padding-bottom"));
  117. parseInt(b(this).css("padding-top"));
  118. if (c.scrollOverflow) {
  119. var a = b(this).find(".slide");
  120. a.length ? a.each(function () {
  121. w(b(this))
  122. }) : w(b(this))
  123. }
  124. c.verticalCentered && b(this).find(".tableCell").css("height",
  125. g + "px");
  126. b(this).css("height", g + "px");
  127. a = b(this).find(".slides");
  128. a.length && u(a, a.find(".slide.active"))
  129. });
  130. b(".section.active").position();
  131. a = b(".section.active");
  132. a.index(".section") && n(a)
  133. }
  134. function S(a, e) {
  135. var c = 825,
  136. f = a;
  137. 825 > a || 900 > e ? (900 > e && (f = e, c = 900), c = (100 * f / c).toFixed(2), b("body").css(
  138. "font-size", c + "%")) : b("body").css("font-size", "100%")
  139. }
  140. function L(a, e) {
  141. c.navigation && (b("#fullPage-nav").find(".active").removeClass("active"), a ? b("#fullPage-nav").find(
  142. 'a[href="#' + a + '"]').addClass("active") : b("#fullPage-nav").find("li").eq(e).find(
  143. "a").addClass("active"))
  144. }
  145. function K(a) {
  146. c.menu && (b(c.menu).find(".active").removeClass("active"), b(c.menu).find('[data-menuanchor="' + a +
  147. '"]').addClass("active"))
  148. }
  149. function v(a, b) {
  150. if ("top" === a) return !b.scrollTop();
  151. if ("bottom" === a) return b.scrollTop() + b.innerHeight() >= b[0].scrollHeight
  152. }
  153. function G(a) {
  154. var c = b(".section.active").index(".section");
  155. a = a.index(".section");
  156. return c > a ? "up" : "down"
  157. }
  158. function w(a) {
  159. a.css("overflow", "hidden");
  160. var b = a.closest(".section"),
  161. d = a.find(".scrollable");
  162. (d.length ? a.find(".scrollable").get(0).scrollHeight -
  163. parseInt(b.css("padding-bottom")) - parseInt(b.css("padding-top")) : a.get(0).scrollHeight -
  164. parseInt(b.css("padding-bottom")) - parseInt(b.css("padding-top"))) > g ? (b = g - parseInt(b.css(
  165. "padding-bottom")) - parseInt(b.css("padding-top")), d.length ? d.css("height", b +
  166. "px").parent().css("height", b + "px") : (c.verticalCentered ? a.find(".tableCell").wrapInner(
  167. '<div class="scrollable" />') : a.wrapInner('<div class="scrollable" />'), a.find(
  168. ".scrollable").slimScroll({
  169. height: b + "px",
  170. size: "10px",
  171. alwaysVisible: !0
  172. }))) : (a.find(".scrollable").children().first().unwrap().unwrap(),
  173. a.find(".slimScrollBar").remove(), a.find(".slimScrollRail").remove());
  174. a.css("overflow", "")
  175. }
  176. function N(a) {
  177. a.addClass("table").wrapInner('<div class="tableCell" style="height:' + g + 'px;" />')
  178. }
  179. function z(a, c) {
  180. b("#superContainer").toggleClass("easing", c);
  181. b("#superContainer").css({
  182. "-webkit-transform": a,
  183. "-moz-transform": a,
  184. "-ms-transform": a,
  185. transform: a
  186. })
  187. }
  188. function A(a, c) {
  189. var d = isNaN(a) ? b('[data-anchor="' + a + '"]') : b(".section").eq(a - 1);
  190. a === r || d.hasClass("active") ? O(d, c) : n(d, function () {
  191. O(d, c)
  192. })
  193. }
  194. function O(a, b) {
  195. if ("undefined" !=
  196. typeof b) {
  197. var c = a.find(".slides"),
  198. f = c.find('[data-anchor="' + b + '"]');
  199. f.length || (f = c.find(".slide").eq(b));
  200. f.length && u(c, f)
  201. }
  202. }
  203. function T(a, b) {
  204. a.append('<div class="fullPage-slidesNav"><ul></ul></div>');
  205. var d = a.find(".fullPage-slidesNav");
  206. d.addClass(c.slidesNavPosition);
  207. for (var f = 0; f < b; f++) d.find("ul").append('<li><a href="#"><span></span></a></li>');
  208. d.css("margin-left", "-" + d.width() / 2 + "px");
  209. d.find("li").first().find("a").addClass("active")
  210. }
  211. function I(a, b, c) {
  212. var f = "";
  213. a ? ("undefined" !== typeof c && (f = c),
  214. "undefined" === typeof b && (b = a), P = b, location.hash = f + "/" + b) : location.hash =
  215. c
  216. }
  217. function U() {
  218. var a = document.createElement("p"),
  219. b, c = {
  220. webkitTransform: "-webkit-transform",
  221. OTransform: "-o-transform",
  222. msTransform: "-ms-transform",
  223. MozTransform: "-moz-transform",
  224. transform: "transform"
  225. };
  226. document.body.insertBefore(a, null);
  227. for (var f in c) void 0 !== a.style[f] && (a.style[f] = "translate3d(1px,1px,1px)", b = window.getComputedStyle(
  228. a).getPropertyValue(c[f]));
  229. document.body.removeChild(a);
  230. return void 0 !== b && 0 < b.length && "none" !== b
  231. }
  232. c = b.extend({
  233. verticalCentered: !0,
  234. resize: !0,
  235. slidesColor: [],
  236. anchors: [],
  237. scrollingSpeed: 700,
  238. easing: "easeInQuart",
  239. menu: !1,
  240. navigation: !1,
  241. navigationPosition: "right",
  242. navigationColor: "#000",
  243. navigationTooltips: [],
  244. slidesNavigation: !1,
  245. slidesNavPosition: "bottom",
  246. controlArrowColor: "#fff",
  247. loopBottom: !1,
  248. loopTop: !1,
  249. loopHorizontal: !0,
  250. autoScrolling: !0,
  251. scrollOverflow: !1,
  252. css3: !1,
  253. paddingTop: 0,
  254. paddingBottom: 0,
  255. fixedElements: null,
  256. normalScrollElements: null,
  257. afterLoad: null,
  258. onLeave: null,
  259. afterRender: null,
  260. afterSlideLoad: null,
  261. onSlideLeave: null
  262. },
  263. c);
  264. var J = 700;
  265. b.fn.fullpage.setAutoScrolling = function (a) {
  266. c.autoScrolling = a;
  267. a = b(".section.active");
  268. c.autoScrolling ? (b("html, body").css({
  269. overflow: "hidden",
  270. height: "100%"
  271. }), a.length && (c.css3 ? (a = "translate3d(0px, -" + a.position().top + "px, 0px)", z(
  272. a, !1)) : b("#superContainer").css("top", "-" + a.position().top + "px"))) : (b(
  273. "html, body").css({
  274. overflow: "auto",
  275. height: "auto"
  276. }), c.css3 ? z("translate3d(0px, 0px, 0px)", !1) : b("#superContainer").css("top",
  277. "0px"), b("html, body").scrollTop(a.position().top))
  278. };
  279. var s = !1,
  280. B = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|Windows Phone)/),
  281. g = b(window).height(),
  282. k = !1,
  283. r, P;
  284. F();
  285. c.css3 && (c.css3 = U());
  286. b("body").wrapInner('<div id="superContainer" />');
  287. if (c.navigation) {
  288. b("body").append('<div id="fullPage-nav"><ul></ul></div>');
  289. var t = b("#fullPage-nav");
  290. t.css("color", c.navigationColor);
  291. t.addClass(c.navigationPosition)
  292. }
  293. b(".section").each(function (a) {
  294. var e = b(this).find(".slide"),
  295. d = e.length;
  296. a || b(this).addClass("active");
  297. b(this).css("height", g + "px");
  298. (c.paddingTop || c.paddingBottom) && b(this).css("padding", c.paddingTop + " 0 " + c.paddingBottom +
  299. " 0");
  300. "undefined" !==
  301. typeof c.slidesColor[a] && b(this).css("background-color", c.slidesColor[a]);
  302. "undefined" !== typeof c.anchors[a] && b(this).attr("data-anchor", c.anchors[a]);
  303. if (c.navigation) {
  304. var f = "";
  305. c.anchors.length && (f = c.anchors[a]);
  306. a = c.navigationTooltips[a];
  307. "undefined" === typeof a && (a = "");
  308. t.find("ul").append('<li data-tooltip="' + a + '"><a href="#' + f +
  309. '"><span></span></a></li>')
  310. }
  311. if (0 < d) {
  312. var f = 100 * d,
  313. h = 100 / d;
  314. e.wrapAll('<div class="slidesContainer" />');
  315. e.parent().wrap('<div class="slides" />');
  316. b(this).find(".slidesContainer").css("width",
  317. f + "%");
  318. b(this).find(".slides").after(
  319. '<div class="controlArrow prev"></div><div class="controlArrow next"></div>');
  320. b(this).find(".controlArrow.next").css("border-color",
  321. "transparent transparent transparent " + c.controlArrowColor);
  322. b(this).find(".controlArrow.prev").css("border-color", "transparent " + c.controlArrowColor +
  323. " transparent transparent");
  324. c.loopHorizontal || b(this).find(".controlArrow.prev").hide();
  325. c.slidesNavigation && T(b(this), d);
  326. e.each(function (a) {
  327. a || b(this).addClass("active");
  328. b(this).css("width",
  329. h + "%");
  330. c.verticalCentered && N(b(this))
  331. })
  332. } else c.verticalCentered && N(b(this))
  333. }).promise().done(function () {
  334. b.fn.fullpage.setAutoScrolling(c.autoScrolling);
  335. b.isFunction(c.afterRender) && c.afterRender.call(this);
  336. c.fixedElements && c.css3 && b(c.fixedElements).appendTo("body");
  337. c.navigation && (t.css("margin-top", "-" + t.height() / 2 + "px"), t.find("li").first().find(
  338. "a").addClass("active"));
  339. c.menu && c.css3 && b(c.menu).appendTo("body");
  340. if (c.scrollOverflow) b(window).on("load", function () {
  341. b(".section").each(function () {
  342. var a =
  343. b(this).find(".slide");
  344. a.length ? a.each(function () {
  345. w(b(this))
  346. }) : w(b(this))
  347. })
  348. });
  349. b(window).on("load", function () {
  350. var a = window.location.hash.replace("#", "").split("/"),
  351. b = a[0],
  352. a = a[1];
  353. b && A(b, a)
  354. })
  355. });
  356. var Q, C = !1;
  357. b(window).scroll(function (a) {
  358. if (!c.autoScrolling) {
  359. var e = b(window).scrollTop();
  360. a = b(".section").map(function () {
  361. if (b(this).offset().top < e + 100) return b(this)
  362. });
  363. a = a[a.length - 1];
  364. if (!a.hasClass("active")) {
  365. C = !0;
  366. var d = G(a);
  367. b(".section.active").removeClass("active");
  368. a.addClass("active");
  369. var f = a.data("anchor");
  370. b.isFunction(c.onLeave) && c.onLeave.call(this, a.index(".section"), d);
  371. b.isFunction(c.afterLoad) && c.afterLoad.call(this, f, a.index(".section") + 1);
  372. K(f);
  373. L(f, 0);
  374. c.anchors.length && !k && (r = f, location.hash = f);
  375. clearTimeout(Q);
  376. Q = setTimeout(function () {
  377. C = !1
  378. }, 100)
  379. }
  380. }
  381. });
  382. var D = 0,
  383. x = 0,
  384. E = 0,
  385. y = 0;
  386. b(document).on("touchmove", function (a) {
  387. if (c.autoScrolling && B) {
  388. a.preventDefault();
  389. a = a.originalEvent;
  390. var e = b(".section.active");
  391. if (!k && !s)
  392. if (E = a.touches[0].pageY, y = a.touches[0].pageX, e.find(".slides").length &&
  393. Math.abs(x - y) > Math.abs(D -
  394. E)) x > y ? e.find(".controlArrow.next").trigger("click") : x < y && e.find(
  395. ".controlArrow.prev").trigger("click");
  396. else if (a = e.find(".slides").length ? e.find(".slide.active").find(".scrollable") :
  397. e.find(".scrollable"), D > E)
  398. if (0 < a.length)
  399. if (v("bottom", a)) b.fn.fullpage.moveSectionDown();
  400. else return !0;
  401. else b.fn.fullpage.moveSectionDown();
  402. else if (0 < a.length)
  403. if (v("top", a)) b.fn.fullpage.moveSectionUp();
  404. else return !0;
  405. else b.fn.fullpage.moveSectionUp()
  406. }
  407. });
  408. b(document).on("touchstart", function (a) {
  409. c.autoScrolling && B && (a =
  410. a.originalEvent, D = a.touches[0].pageY, x = a.touches[0].pageX)
  411. });
  412. b.fn.fullpage.moveSectionUp = function () {
  413. var a = b(".section.active").prev(".section");
  414. c.loopTop && !a.length && (a = b(".section").last());
  415. (0 < a.length || !a.length && c.loopTop) && n(a)
  416. };
  417. b.fn.fullpage.moveSectionDown = function () {
  418. var a = b(".section.active").next(".section");
  419. c.loopBottom && !a.length && (a = b(".section").first());
  420. (0 < a.length || !a.length && c.loopBottom) && n(a)
  421. };
  422. b.fn.fullpage.moveTo = function (a, c) {
  423. var d = "",
  424. d = isNaN(a) ? b('[data-anchor="' + a + '"]') : b(".section").eq(a -
  425. 1);
  426. "undefined" !== c ? A(a, c) : 0 < d.length && n(d)
  427. };
  428. b(window).on("hashchange", function () {
  429. if (!C) {
  430. var a = window.location.hash.replace("#", "").split("/"),
  431. b = a[0],
  432. a = a[1],
  433. c = "undefined" === typeof r,
  434. f = "undefined" === typeof r && "undefined" === typeof a;
  435. (b && b !== r && !c || f || "undefined" !== typeof a && !s && P != a) && A(b, a)
  436. }
  437. });
  438. b(document).keydown(function (a) {
  439. if (!k) switch (a.which) {
  440. case 38:
  441. case 33:
  442. b.fn.fullpage.moveSectionUp();
  443. break;
  444. case 40:
  445. case 34:
  446. b.fn.fullpage.moveSectionDown();
  447. break;
  448. case 37:
  449. b(".section.active").find(".controlArrow.prev").trigger("click");
  450. break;
  451. case 39:
  452. b(".section.active").find(".controlArrow.next").trigger("click")
  453. }
  454. });
  455. b(document).on("click", "#fullPage-nav a", function (a) {
  456. a.preventDefault();
  457. a = b(this).parent().index();
  458. n(b(".section").eq(a))
  459. });
  460. b(document).on({
  461. mouseenter: function () {
  462. var a = b(this).data("tooltip");
  463. b('<div class="fullPage-tooltip ' + c.navigationPosition + '">' + a + "</div>").hide()
  464. .appendTo(b(this)).fadeIn(200)
  465. },
  466. mouseleave: function () {
  467. b(this).find(".fullPage-tooltip").fadeOut().remove()
  468. }
  469. }, "#fullPage-nav li");
  470. c.normalScrollElements &&
  471. (b(document).on("mouseover", c.normalScrollElements, function () {
  472. document.addEventListener ? (document.removeEventListener("mousewheel", m, !1),
  473. document.removeEventListener("DOMMouseScroll", m, !1)) : document.detachEvent(
  474. "onmousewheel", m)
  475. }), b(document).on("mouseout", c.normalScrollElements, function () {
  476. F()
  477. }));
  478. b(".section").on("click", ".controlArrow", function () {
  479. if (!s) {
  480. s = !0;
  481. var a = b(this).closest(".section").find(".slides"),
  482. c = a.find(".slide.active"),
  483. d = null,
  484. d = b(this).hasClass("prev") ? c.prev(".slide") : c.next(".slide");
  485. d.length || (d = b(this).hasClass("prev") ? c.siblings(":last") : c.siblings(":first"));
  486. u(a, d)
  487. }
  488. });
  489. b(".section").on("click", ".toSlide", function (a) {
  490. a.preventDefault();
  491. a = b(this).closest(".section").find(".slides");
  492. a.find(".slide.active");
  493. var c = null,
  494. c = a.find(".slide").eq(b(this).data("index") - 1);
  495. 0 < c.length && u(a, c)
  496. });
  497. if (!B) {
  498. var R;
  499. b(window).resize(function () {
  500. clearTimeout(R);
  501. R = setTimeout(M, 500)
  502. })
  503. }
  504. b(window).bind("orientationchange", function () {
  505. M()
  506. });
  507. b(document).on("click", ".fullPage-slidesNav a", function (a) {
  508. a.preventDefault();
  509. a = b(this).closest(".section").find(".slides");
  510. var c = a.find(".slide").eq(b(this).closest("li").index());
  511. u(a, c)
  512. })
  513. }
  514. })(jQuery);