123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- var $cards = $('#items .full-works');
- var $card = $('#items .card');
- var $cat = $('.cat-list .cat a');
- var $img = $('.item #items .img');
- function masonry() {
- var $grid = $cards.masonry({
- itemSelector: '.card',
- columnWidth: '.card',
- percentPosition: true,
- transitionDuration: '0.2s'
- });
- var $grid2 = $img.masonry({
- itemSelector: '.img-card',
- columnWidth: '.img-card',
- percentPosition: true,
- gutter: 20,
- transitionDuration: '0.2s'
- });
- $grid.imagesLoaded().progress( function() {
- $grid.masonry();
- });
- $grid2.imagesLoaded().progress( function() {
- $grid2.masonry();
- });
- }
- function contact() {
- var $contact = $('header .contact');
- $contact.on('click',function() {
- if ($(this).hasClass('open')) {
- $(this).removeClass('open');
- $(this).addClass('close');
- } else {
- $(this).addClass('open');
- $(this).removeClass('close');
- }
- })
- }
- function scroll() {
- // left: 37, up: 38, right: 39, down: 40,
- // spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
- if ($('#page-wrapper.blog').length > 0){
- $(window).bind('mousewheel DOMMouseScroll', function(event){
- var $height = $(window).scrollTop();
- var $heightW = $(window).height();
- var wh = $heightW - $height;
- var keys = {32: 1, 37: 1, 38: 1, 39: 1, 40: 1};
- function preventDefault(e) {
- e = e || window.event;
- if (e.preventDefault)
- e.preventDefault();
- e.returnValue = false;
- }
- function preventDefaultForScrollKeys(e) {
- if (keys[e.keyCode]) {
- preventDefault(e);
- return false;
- }
- }
- function disablescroll() {
- if (window.addEventListener) // older FF
- window.addEventListener('DOMMouseScroll', preventDefault, false);
- window.onwheel = preventDefault; // modern standard
- window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
- window.ontouchmove = preventDefault; // mobile
- document.ontouchmove = function(e) {
- var target = e.currentTarget;
- while(target) {
- if(checkIfElementShouldScroll(target))
- return;
- target = target.parentNode;
- }
- e.preventDefault();
- };
- document.onkeydown = preventDefaultForScrollKeys;
- }
- function enableScroll() {
- if (window.removeEventListener)
- window.removeEventListener('DOMMouseScroll', preventDefault, false);
- window.onmousewheel = document.onmousewheel = null;
- window.onwheel = null;
- window.ontouchmove = null;
- document.onkeydown = null;
- var aTag = $("#start");
- $('html,body').animate({scrollTop: aTag.offset().top},'slow');
- }
- if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
- if (wh > 0) {
- console.log('up');
- $('.blog header').removeClass('hide');
- $('.blog #start').removeClass('visible');
- // disablescroll();
- // setTimeout(enableScroll, 500);
- $('.blog #start #items').removeClass('fixed');
- }
- }else {
- if (wh > 0) {
- console.log('down');
- $('.blog header').addClass('hide');
- $('.blog #start').addClass('visible');
- disablescroll();
- setTimeout(enableScroll, 500);
- $('.blog #start #items').addClass('fixed');
- }
- }
- });
- }
- }
- jQuery(document).ready(function($){
- masonry();
- contact();
- scroll();
- $(window).load(function(){
- $('html, body').scrollTop(0);
- });
- });
|