Skip to content
Snippets Groups Projects
Select Git revision
  • ed31e06c06c56ad0f95c47af11d71862fd8b2ecb
  • master default protected
  • rednatco-v2
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • servers
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

generic.ts

Blame
  • bindings.ts 1.75 KiB
    /**
     * Copyright (c) 2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
     *
     * @author Alexander Rose <alexander.rose@weirdbyte.de>
     */
    
    import { ButtonsType, ModifiersKeys } from '../../mol-util/input/input-observer';
    
    const B = ButtonsType
    const M = ModifiersKeys
    
    export interface Bindings {
        drag: {
            rotate: Bindings.Trigger
            rotateZ: Bindings.Trigger
            pan: Bindings.Trigger
            zoom: Bindings.Trigger
            focus: Bindings.Trigger
            focusZoom: Bindings.Trigger
        },
        scroll: {
            zoom: Bindings.Trigger
            focus: Bindings.Trigger
            focusZoom: Bindings.Trigger
        }
    }
    
    export namespace Bindings {
        export type Trigger = { buttons: ButtonsType, modifiers?: ModifiersKeys }
        export const EmptyTrigger = { buttons: ButtonsType.Flag.None }
    
        export function match(trigger: Trigger, buttons: ButtonsType, modifiers: ModifiersKeys) {
            const { buttons: b, modifiers: m } = trigger
            return ButtonsType.has(b, buttons) &&
                (!m || ModifiersKeys.areEqual(m, modifiers))
        }
    
        export const Default: Bindings = {
            drag: {
                rotate: { buttons: B.Flag.Primary, modifiers: M.create() },
                rotateZ: { buttons: B.Flag.Primary, modifiers: M.create({ shift: true }) },
                pan: { buttons: B.Flag.Secondary, modifiers: M.create() },
                zoom: EmptyTrigger,
                focus: { buttons: B.Flag.Forth, modifiers: M.create() },
                focusZoom: { buttons: B.Flag.Auxilary, modifiers: M.create() },
            },
            scroll: {
                zoom: { buttons: B.Flag.Auxilary, modifiers: M.create() },
                focus: { buttons: B.Flag.Auxilary, modifiers: M.create({ shift: true }) },
                focusZoom: EmptyTrigger,
            }
        }
    }