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
// Test data | |
it('sets the correct default data', () => { | |
const defaultData = MyComponent.data() | |
expect(defaultData.message).toBe('hello!') | |
}) | |
// Test method | |
it('message method working correct', () => { | |
const defaultData = MyComponent.methods | |
expect(defaultData.message()).toBe('hello!') |
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
// Test element after render | |
it('renders the correct message', () => { | |
const Ctor = Vue.extend(MyComponent) | |
const vm = new Ctor().$mount() | |
expect(vm.$el.textContent).toBe('bye!') | |
vm.$el.querySelector('i.fa-smile-o').should.exist | |
}) | |
//Test method after render | |
it('method work correctly', () => { |
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
let documentIsHidden = false; | |
document.addEventListener('visibilitychange', () => { | |
// เช็คว่า หน้านี้ถูกซ่อนหรือเปิดอยู่ ตอนที่มี event visibilitychange trigger มา | |
documentIsHidden = document.hidden; | |
}); | |
function update() { | |
if (!documentIsHidden) { | |
// Request server หรือ update ตามปกติถ้าเว็บเปิดอยู่ |
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
function a(){ | |
return new Promise((resolve,reject) => { | |
resolve(res) | |
} | |
} |
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
function b(){ | |
return Promise.resolve(res) | |
} |
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
async function c(){ | |
return res | |
} |
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
import Vue from 'vue' | |
// include vue-custom-element plugin to Vue | |
import VueCustomElement from 'vue-custom-element' | |
Vue.use(VueCustomElement) | |
// import and register your component(s) | |
import ShareButtonsComponent from './components/ShareButtonsComponent' | |
Vue.customElement('share-buttons', ShareButtonsComponent) |
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
// ประกาศสร้าง instance ของ IntersectionObserver พร้อมบอกด้วยว่า ก่อนแสดงผล 50 pixel ให้ trigger ไปหา callback | |
const contatiner = document.getElementById('image') | |
const observer = new IntersectionObserver(onIntersection, {rootMargin: '50px 0px'}) | |
// บอกว่าให้เฝ้า id="image" เอาไว้ | |
observer.observe(contatiner) | |
function onIntersection (entry) { | |
let element = entry[0] | |
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
import React from 'react'; | |
import { | |
AppRegistry, | |
asset, | |
Pano, | |
Text, | |
View, | |
VrButton, | |
} from 'react-vr'; |
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
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script> | |
<script> | |
AFRAME.registerComponent('change-sky', { | |
schema: { | |
skyUrl : {default: 'chess-world.jpg'} | |
}, | |
init: function () { | |
let data = this.data; |