Skip to content

Instantly share code, notes, and snippets.

@Bachana123
Bachana123 / uppercase problem
Created December 24, 2020 14:02
sometime you have to enable uppercase for some fonts
.uppercase {
font-feature-settings: 'case' on;
}
/////// install first
npm i -D scrollmagic gsap scrollmagic-plugin-gsap
/////// plugin
/* eslint-disable import/no-webpack-loader-syntax */
import Vue from 'vue'
import { TweenMax, TimelineMax } from 'gsap'
import * as ScrollMagic from 'scrollmagic'
mounted() {
const pixelScript = this.shareInfo.pixelScript
const analyticsScript = this.shareInfo.analyticsScript
if (pixelScript.includes('<script>')) {
document.body.appendChild(this.htmlToElements(pixelScript))
}
if (analyticsScript.includes('<script>')) {
document.body.appendChild(this.htmlToElements(analyticsScript))
}
@Bachana123
Bachana123 / mousedown, click outside
Created June 13, 2020 20:38
mousedown, click outside
import Vue from 'vue'
Vue.directive('mouse-down', {
bind: function (el, binding, vnode) {
el.clickOutsideEvent = function (event) {
// here I check that click was outside the el and his childrens
if (!(el == event.target || el.contains(event.target))) {
// and if it did, call method provided in attribute value
vnode.context[binding.expression](event);
}
@Bachana123
Bachana123 / scrolling with arrow
Last active May 23, 2020 12:55
scrolling with arrow
chooseWithArrows(e) {
const SCROLL_BOX = this.$refs.scrollWithArrow
let scrollDiv;
if (e.keyCode == '38') {
//check if i is smaller than 0
this.i - 1 < 0 ? this.i = this.searchHendler.length-1 : this.i -=1;
//add animation using this variable
this.scrollTo = this.searchHendler[this.i][this.name]
//check offset of child component
scrollDiv = SCROLL_BOX.childNodes[this.i].offsetTop
@Bachana123
Bachana123 / input v-show
Created May 23, 2020 11:28
add focus effect after v-show is true
this.$nextTick(() => {
this.$refs.searchInput.focus();
})
@Bachana123
Bachana123 / make a function variable
Created May 19, 2020 15:47
make a function variable
```
answer() {
const answer = this.text.answer
const splitedAnswer = answer.split(';')
if (splitedAnswer.length > 1) {
const createNode = (x) => '<li>' + x + '</li>'
const list = splitedAnswer.map(createNode)
return '<ul>' + list.join('') + '</ul>'
}
return answer
<template>
<section>
<svg class="" height="20" width="20" viewBox="0 0 20 20">
<circle r="10" cx="10" cy="10" fill="white" />
<circle v-for="(item, index) in pie" :key="index" r="5" cx="10" cy="10" fill="transparent"
stroke="tomato"
stroke-width="10"
:stroke-dasharray="item.width + ' 31.42'"
:transform="'rotate(' + item.rotate + ')'" />
<circle r="5" cx="10" cy="10" fill="white" stroke-width="0"/>
@Bachana123
Bachana123 / line clamp
Last active April 15, 2020 19:40
line clamp
:style="`display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; text-overflow: ellipsis; -webkit-line-clamp: ${};`"
var checkScrollSpeed = (function(settings){
settings = settings || {};
var lastPos, newPos, timer, delta,
delay = settings.delay || 50; // in "ms" (higher means lower fidelity )
function clear() {
lastPos = null;
delta = 0;
}