Skip to content

Instantly share code, notes, and snippets.

function mouseMoving(element, movementSpeed = 1) {
if (typeof element == 'string') {
element = $(element);
};
element.css({
'position': 'relative'
});
$(document).on('mousemove', function(event) {
let x = event.pageX * 100 / $(document).innerWidth();
let y = event.pageY * 100 / $(document).innerHeight();
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, user-scalable=yes, shrink-to-fit=no">
function waitBy(byThis, diffThis = 'undefined', maxWait = 10000){
return new Promise(function(resolve, reject){
if( typeof byThis == 'string' ){
let waitPromise = setInterval(function(){
if( typeof top[byThis] != diffThis ){
clearInterval(waitPromise);
resolve(true);
};
}, 10);
let waitPromiseReject = setTimeout(function(){
new Promise(function(resolve, reject){
setTimeout(function(){
resolve(true);
}, 5000);
setTimeout(function(){
resolve(false);
}, 10000);
}).then(function(val){
if(val == true){
//...
/* https://getbootstrap.com/docs/4.0/layout/grid/ */
.no-gutters {
margin-right: 0;
margin-left: 0;
}
.no-gutters > .col,
.no-gutters > [class*='col-']{
padding-right: 0;
padding-left: 0;
}
jQuery.fn.extend({
indexOf: function(selector) {
let thisElement = $(this);
if ($(this).constructor == $().constructor) {
if (typeof selector == 'undefined') {
return $(this).index();
};
if (!$(this).is(selector)) {
console.error('This element is not equal to the selector.');
return stopError;
jQuery.fn.extend({indexOf:function(a){let b=$(this);if($(this).constructor==$().constructor){if('undefined'==typeof a)return $(this).index();if(!$(this).is(a))return console.error('This element is not equal to the selector.'),stopError;let c=-1;return $(this).parent().children().each(function(){if($(this).is(a)&&c++,$(this).is(b))return!1}),c}return console.error('The "indexOf" function only accepts jquery elements.'),stopError}});
$(function(){
//console.info('menu menuHighlight running');
let menuElement = $('.mc-menu')
, allElements = $('.mc-menu__top__logo, .mc-menu__top__menu-button')
, anchorMap = [];
$('.mc-menu__top__logo, .mc-menu__top__menu-button').each(function(){
anchorMap.push( $( $(this).attr('href') ) );
});
function offset(element, diffInTop, diffInLeft){
return element.offset(diffInTop, diffInLeft);
};
Object.prototype.offset = function(element, diffInTop, diffInLeft){
if( typeof diffInLeft == 'undefined' ){diffInLeft = 0;};
if( typeof diffInTop == 'undefined' ){diffInTop = 0;};
if( typeof element == 'undefined' ){element = 0;};
if( this != window ){
diffInLeft = diffInTop;