Giter VIP home page Giter VIP logo

svelte-hammer's Introduction

Beomy.js

View 단을 처리하는 MVVM 형태의 프레임워크 입니다.

Vue.js의 옵션 형태와 Data Binding, React.js의 render 함수를 합친 형태입니다. sample 디렉토리에 사용 예제 한가지를 업로드 하였습니다.

사용 방법

기본 사용 방법은 아래 코드와 같습니다.

const beomy = new Beomy({
    el: #beomy-root, // 바인딩할 HTML의 root element를 정의합니다.
    data () {
        // View와 바인딩할 값들을 정의합니다.
    },
    method: {
        // 바인딩 한 값들을 가공하기 위한 함수들을 정의합니다.
    },
    render () {
        // el 옵션에 정의한 element 밑으로 그려질 DOM을 리턴하는 함수입니다.
    }
})

Data Binding 원리

Vue.js의 Data Binding 형태를 따랐습니다.

Object.defineProperty

Object.defineProperty를 사용하여 data 옵션에 정의 된 값들을 get과 set으로 분리하였습니다. data 옵션에 정의 된 값이 set이 될 경우, render 함수가 호출됩니다.

Oject 안에 있는 Object (2중 구조)까지 Data Binding을 지원 합니다.

data () {
    return {
        objInObj: {
            obj: 'test' // 2중 구조까지 Data Bindg을 지원합니다.
        }
    }
}

Array

Array의 Data Binding을 위해 push, pop, shift, unshift, splice, sort,reverse 함수를 재정의 하였습니다. 위의 7가지 메소드를 사용하지 않고 Array의 값을 변경할 경우 Data Binding을 지원하지 않습니다.

let list = [1, 2, 3]
list.push(4) // Data Binding 됩니다.
list[2] = 4 // Data Binding 되지 않습니다.

render

data 옵션에 정의 된 값들이 변경 될 경우 render 함수가 호출됩니다. render 함수의 반환 값을 Object.defineProperty 메소드를 사용하여 get, set으로 분리하였습니다. render 함수가 반환 하는 HTML 값이 이전 HTML 값과 다를 때 DOM을 다시 그리는 간단한 구조입니다.

DoTo List

  1. Component 구조화
  2. Event 바인딩
  3. Virtual DOM

svelte-hammer's People

Contributors

beomy avatar jeffjose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

svelte-hammer's Issues

Error with hammer library

When I try to run my app with rollup -c -w I get the following error and can't compile:

SyntaxError: Unexpected token (6:12644) in ...../node_modules/svelte-hammer/dist/bundle.js

The thing is that if I try to use hammerjs alone (without svelte-hammer) I also get a similar error... any ideas on what's going on?

Thanks!

Import events not working

I was trying to use any events, but it's getting error Error: 'pan' is not exported by node_modules/svelte-hammer/dist/bundle.js

Not working with npm install

I'm getting error while trying to work with this lib and it seems the npm package doesn't have any .js files at all:

Screen Shot 2020-02-17 at 17 54 53

It just installs package.json and README.md.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.