forked from bruno-salmito/WebSite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Versão 0.0.5 Add pages and css bugs fix
- Loading branch information
1 parent
b166aae
commit 5bfc00c
Showing
10 changed files
with
724 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Script que contrala as animações da página principal | ||
* Para utilizar basta adicionar na tag html o attr | ||
* data-anime. | ||
* Autor: Bruno Salmito Filizola | ||
* Versão: 0.1 | ||
*/ | ||
|
||
/** | ||
* Função para otimizar as animações | ||
* @param {*} func (Passar a função para o debounce) | ||
* @param {*} wait (O tempo que irá aguardar para executar novamente) | ||
* @param {*} immediate | ||
*/ | ||
|
||
function debounce(func, wait, immediate) { | ||
var timeout; | ||
return function () { | ||
var context = this, | ||
args = arguments; | ||
var later = function () { | ||
timeout = null; | ||
if (!immediate) func.apply(context, args); | ||
}; | ||
var callNow = immediate && !timeout; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
if (callNow) func.apply(context, args); | ||
}; | ||
}; | ||
|
||
/** | ||
* Função animeScroll | ||
*/ | ||
|
||
|
||
/** | ||
* Quando o usuário declarar o attributo data-anime ativa o scroll | ||
* quando fizer o scroll executa as animações com o atributo | ||
*/ | ||
const target = document.querySelectorAll('[data-anime]'); | ||
|
||
function animeScroll() { | ||
const windowTop = window.pageYOffset + ((window.innerHeight * 3) / 4); | ||
target.forEach(function (element) { | ||
if ((windowTop) > element.offsetTop) { | ||
//Adiciona a classe que controla a animação | ||
element.classList.add('animateContent'); | ||
} else { | ||
//Remove a classe que controla a animação | ||
element.classList.remove('animateContent'); | ||
} | ||
}) | ||
} //Fim da function animeScroll | ||
|
||
animeScroll(); | ||
/** | ||
* Verifica se existem as targets e se existir | ||
* fica ouvindo o scrool otimizado com o debounce | ||
*/ | ||
if (target.length) { | ||
window.addEventListener('scroll', debounce(function () { | ||
animeScroll(); | ||
}, 200)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Script para adicionar mascará nos formulários | ||
* Para utilizar basta adicionar na tag html o attr | ||
* data-input="NOME do Controle". | ||
* Autor: Bruno Salmito Filizola | ||
* Versão: 0.1 | ||
*/ | ||
|
||
//Objeto mask para adicionar maskara aos campos do formulário | ||
const mask = { | ||
cpf(value) { | ||
return value | ||
.replace(/\D/g, '') | ||
//D somente números | ||
//d somente letras | ||
//g global | ||
.replace(/(\d{3})(\d)/, '$1.$2') | ||
.replace(/(\d{3})(\d)/, '$1.$2') | ||
.replace(/(\d{3})(\d{1,2})/, '$1-$2') | ||
.replace(/(-\d{2})\d+?$/, '$1') | ||
}, | ||
cnpj(value) { | ||
return value | ||
//nao aceita nada além de número | ||
.replace(/\D/g, '') | ||
.replace(/(\d{2})(\d)/, '$1.$2') | ||
.replace(/(\d{3})(\d)/, '$1.$2') | ||
.replace(/(\d{3})(\d)/, '$1/$2') | ||
.replace(/(\d{3})(\d{1,2})/, '$1-$2') | ||
.replace(/(-\d{2})\d+?$/, '$1') | ||
}, | ||
telefone(value) { | ||
return value | ||
.replace(/\D/g, '') | ||
.replace(/(\d{2})(\d)/, '($1) $2') | ||
.replace(/(\d{4})(\d)/, '$1-$2') | ||
.replace(/(\d{4})-(\d)(\d{4})/, '$1$2-$3') | ||
.replace(/(-\d{4,5})\d+?$/, '$1') | ||
|
||
}, | ||
cep(value) { | ||
return value | ||
.replace(/\D/g, '') | ||
.replace(/(\d{5})(\d)/, '$1-$2') | ||
.replace(/(-\d{3})\d+?$/, '$1') | ||
} | ||
} | ||
|
||
// Pega todos os inputs com data-input e chama o objeto | ||
document.querySelectorAll('input').forEach(($input) => { | ||
const field = $input.dataset.input; | ||
|
||
$input.addEventListener('input', (e) => { | ||
e.target.value = mask[field](e.target.value); | ||
}, false) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let show = true; | ||
let menuShow = true; | ||
|
||
const menuToggle = document.querySelector('.menu-toggle'); | ||
|
||
function menu(element) { | ||
document.querySelector(element).classList.toggle('on', show); | ||
} | ||
|
||
menuToggle.addEventListener('click', () => { | ||
menu('.asside'); | ||
menu('header'); | ||
menu('.content'); | ||
menu('.menu-section'); | ||
show = !show; | ||
}) |
Oops, something went wrong.