Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2 #72

Closed
wants to merge 26 commits into from
Closed

v2 #72

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b886bc6
initial commit for v2
IgorHalfeld Oct 2, 2020
9ff2414
finish MVP
IgorHalfeld Oct 4, 2020
f184472
add netifly badge
IgorHalfeld Oct 4, 2020
d41a90b
fix broken link
IgorHalfeld Oct 4, 2020
fbcc200
enhance docs
IgorHalfeld Oct 4, 2020
129b233
fix for more resolutions
IgorHalfeld Oct 4, 2020
d277fb6
add v2 label on tweet div
IgorHalfeld Oct 4, 2020
5f10520
fix vulnerabilities package-lock
IgorHalfeld Oct 4, 2020
2516227
enhance mobile layout
IgorHalfeld Oct 4, 2020
411f7ba
add donate link
IgorHalfeld Oct 5, 2020
b89cc5a
change configs for pwa module
IgorHalfeld Oct 14, 2020
0d207a4
add animation on change tweets
IgorHalfeld Oct 14, 2020
1573d8d
Chewbacca PR's
AugustoBondanca Oct 20, 2020
1cca832
update img chewbacca
AugustoBondanca Oct 20, 2020
62ed2f9
update img chewbacca
AugustoBondanca Oct 20, 2020
120257c
Merge pull request #78 from AugustoBondanca/patch-2
Oct 20, 2020
442215c
new_person(Julius - Everybody Hates Chris) (#82)
emersonjds Oct 21, 2020
c6fab3d
Footer (#75)
Trocatti Oct 30, 2020
7d60ef2
Atualizado assets do relacionado a pwa (#84)
marcotterra Oct 30, 2020
56b1066
feat: v2 dark mode (#83)
luizcieslak Oct 30, 2020
fdc5ee5
Pabllo vittar tamplate (#86)
ananeridev Oct 30, 2020
5ef5b0f
Fix: Manter tweet digitado ao trocar de template (#85)
omarkdev Nov 3, 2020
8fd7c5f
add baroes
IgorHalfeld Jan 28, 2021
cdfae54
Cria switch-box para alterar origem de Android ou iPhone (#87)
omarkdev May 30, 2021
5dda77f
Adiciona dark mode no tweet (#88)
omarkdev May 30, 2021
cac60b9
Fix scroll in homepage (#95)
rhuangabrielsantos May 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add animation on change tweets
  • Loading branch information
IgorHalfeld committed Oct 14, 2020
commit 0d207a45fa38fbcb0d16daabfc1466fcbee1986e
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"dom-to-image": "^2.6.0",
"gsap": "^3.5.1",
"register-service-worker": "^1.7.1",
"tailwindcss": "^1.8.10",
"vue": "^3.0.0-0"
Expand Down
71 changes: 68 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,81 @@

<script lang="ts">
import { defineComponent, onMounted, onUnmounted, Ref } from 'vue'
import { gsap } from 'gsap'
import CustomHeader from './components/CustomHeader/index.vue'
import TweetViewer from './components/TweetViewer/index.vue'
import Toolbar from './components/Toolbar/index.vue'
import { useStore, setCurrentTweet, setTweetRef, setSearch } from './store'
import { Person, Win } from './types'
import { Person, Win, GSAP } from './types'
import { Persons } from './utils/persons'
import { buildCopyFn, buildDownloadFn } from './utils/domtoimage'

interface AnimationHooks {
onExitFinish(): void;
}
const getHooksDefault = (): AnimationHooks => ({ onExitFinish: () => ({}) })

const ARROW_RIGHT = 39
const ARROW_LEFT = 37

const copy = buildCopyFn(window as unknown as Win)
const download = buildDownloadFn(document)

function buildPreviousAnimateFn (g: GSAP) {
return (tweet: Ref, hooks?: AnimationHooks): void => {
const { onExitFinish } = hooks ?? getHooksDefault()

g.to(tweet, {
duration: 0.3,
ease: 'sine.out',
css: {
opacity: 0,
marginRight: '-200px'
},
onComplete () {
onExitFinish()

const from = { opacity: 0, marginRight: '200px' }
const to = {
duration: 0.3,
ease: 'sine.out',
css: { opacity: 1, marginRight: '0px' }
}
g.fromTo(tweet, from, to)
}
})
}
}

function buildNextAnimateFn (g: GSAP) {
return (tweet: Ref, hooks?: AnimationHooks): void => {
const { onExitFinish } = hooks ?? getHooksDefault()

g.to(tweet, {
duration: 0.3,
ease: 'sine.out',
css: {
opacity: 0,
marginLeft: '-200px'
},
onComplete () {
onExitFinish()

const from = { opacity: 0, marginLeft: '200px' }
const to = {
duration: 0.3,
ease: 'sine.out',
css: { opacity: 1, marginLeft: '0px' }
}
g.fromTo(tweet, from, to)
}
})
}
}

const animatePrevious = buildPreviousAnimateFn(gsap)
const animateNext = buildNextAnimateFn(gsap)

export default defineComponent({
components: {
CustomHeader,
Expand All @@ -53,7 +114,9 @@ export default defineComponent({
}
currentIndex += 1
const tweet = persons[currentIndex]
setCurrentTweet(tweet)
animateNext(store.tweetRef, {
onExitFinish: () => setCurrentTweet(tweet)
})
}

function previousTweet (): void {
Expand All @@ -62,7 +125,9 @@ export default defineComponent({
}
currentIndex -= 1
const tweet = persons[currentIndex]
setCurrentTweet(tweet)
animatePrevious(store.tweetRef, {
onExitFinish: () => setCurrentTweet(tweet)
})
}

function handleKeyup (event: KeyboardEvent): void {
Expand Down
4 changes: 4 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { gsap } from 'gsap'

export type Person = {
name: string;
username: string;
Expand All @@ -21,3 +23,5 @@ export type Win = Window & {
ClipboardItem: ClipboardItemConstructor;
navigator: Navigator;
};

export type GSAP = typeof gsap;