How to use onMouseWheel method in redwood

Best JavaScript code snippet using redwood

index.js

Source:index.js Github

copy

Full Screen

1$(function() {2 // 时间轴动画变量3 var i = 0;4 var n = -1;5 var init = window.onmousewheel;6 var wheel = document.getElementById('his-content');7 // 时间轴动画事件开始8 function tchangeup() {9 n++;10 i -= $('.now')[0].clientHeight;11 $('.list li').eq(0).animate({12 'margin-top': i + 'px'13 }, 1000);14 $('.list-left').eq(n).animate({15 'left': '-190px'16 }, 'fast');17 $('.list-right').eq(n).animate({18 'right': '-420px'19 }, 'fast');20 }21 function tchangedown() {22 i += $('.now')[0].clientHeight;23 $('.list li').eq(0).animate({24 'margin-top': i + 'px'25 }, 700);26 $('.list-left').eq(n).animate({27 'left': '0'28 }, 600);29 $('.list-right').eq(n).animate({30 'right': '0'31 }, 600);32 n--;33 }34 function scrollFunc(e) {35 e = e || window.event; //ie8兼容36 if ((e.wheelDelta > 0 || e.detail < 0) && (($('.list li').length - n) >= 5)) {37 wheel.onmousewheel = null;38 wheel.ontouchstart = null;39 tchangeup();40 setTimeout(function() {41 wheel.onmousewheel = scrollFunc;42 wheel.ontouchstart = touchFunc;43 }, 1000);44 } else if ((e.wheelDelta < 0 || e.detail > 0) && n > -1) {45 wheel.onmousewheel = null;46 wheel.ontouchstart = null;47 tchangedown();48 setTimeout(function() {49 wheel.onmousewheel = scrollFunc;50 wheel.ontouchstart = touchFunc;51 }, 1000);52 }53 }54 // 手机触控动画55 function touchFunc(e) {56 e = e || window.event;57 wheel.ontouchstart = function(e) {58 e = e || window.event;59 startY = e.changedTouches[0].clientY;60 // e.preventDefault();61 wheel.ontouchmove = function(e) {62 e = e || window.event;63 e.preventDefault();64 wheel.ontouchmove = null;65 wheel.onmousewheel = null;66 moveEndY = e.changedTouches[0].clientY;67 Y = moveEndY - startY;68 if ((Y < 0) && (($('.list li').length - n) >= 5)) {69 tchangeup();70 setTimeout(function() {71 wheel.onmousewheel = scrollFunc;72 wheel.ontouchmove = touchFunc;73 }, 1000);74 } else if (Y > 0 && n > -1) {         //↑75 tchangedown();76 setTimeout(function() {77 wheel.onmousewheel = scrollFunc;78 wheel.ontouchmove = touchFunc;79 }, 1000);80 }81 }82 };83 }84 wheel.onmouseover = function() {85 window.onmousewheel = function(e) {86 e = e || window.event;87 if (e.preventDefault) e.preventDefault();88 else e.returnValue = false;89 };90 };91 wheel.onmouseout = function() {92 window.onmousewheel = function(e) {};93 };94 $.ajax({95 type: "GET",96 data: {97 "lm": 1098 },99 dataType: "json",100 url: "./blog/search.php",101 success: function(data) {102 $.each(data.article, function(i, item) {103 var node = $('.clone-item').eq(0).clone(true);104 node.attr('id', item.id);105 node.attr('cl', item.cl);106 node.attr('author', item.author);107 node.find('a').attr('href', './blog/?cl=' + item.cl + '&id=' + item.id);108 node.find('.badge').html(item.time.substring(0, 10));109 node.find('.Lname').html(item.title);110 node.removeClass("hide");111 $('.blogL').append(node);112 });113 }114 });115 $.ajax({116 type: "GET",117 dataType: "json",118 url: "./model/member.php",119 success: function(data) {120 $.each(data.pep, function(i, item) {121 var node = $('.clone-item1').eq(0).clone(true);122 node.find('.badge').html(item.aspect);123 node.find('.Cname').html(item.name);124 node.removeClass("hide");125 $('.list-group').eq(1).append(node);126 });127 }128 });129 $.ajax({130 type: "GET",131 data: {132 "lm": 10133 },134 dataType: "json",135 url: "./act/search.php",136 success: function(data) {137 $.each(data.activity, function(i, item) {138 var node = $('.clone-item').eq(0).clone(true);139 node.attr('id', item.id);140 node.attr('cl', item.cl);141 node.attr('author', item.author);142 node.find('a').attr('href', './act/?cl=' + item.cl + '&id=' + item.id);143 node.find('.badge').html(item.time.substring(0, 10));144 node.find('.Lname').html(item.title);145 node.removeClass("hide");146 $('.activeL').append(node);147 });148 }149 });150 $('#up').click(function() {151 if (($('.list li').length - n) >= 5) {152 wheel.ontouchstart = null;153 wheel.onmousewheel = null;154 tchangeup();155 setTimeout(function() {156 wheel.ontouchstart = touchFunc;157 wheel.onmousewheel = scrollFunc;158 }, 1000);159 }160 });161 $('#down').click(function() {162 if (n > -1) {163 wheel.ontouchstart = null;164 wheel.onmousewheel = null;165 tchangedown();166 setTimeout(function() {167 wheel.ontouchstart = touchFunc;168 wheel.onmousewheel = scrollFunc;169 }, 1000);170 }171 });172 // 注册滚轮事件173 if (wheel.addEventListener) {174 wheel.addEventListener('DOMMouseScroll', scrollFunc, false);175 } // W3C,兼容Firefox176 wheel.onmousewheel = scrollFunc; //IE/Opera/Chrome/Safari177 // 手机触控事件178 wheel.ontouchstart = touchFunc;179 $('#up,#down').css('cursor', 'pointer');180 // 时间轴动画事件结束181 // 时间轴圆点182 $('.list li').mousemove(function() {183 $('.list li').removeClass('now');184 $(this).addClass('now');185 });186 $('#logo').click(function() {187 $('#main').fadeToggle(0);188 $('#time').fadeToggle(0);189 });...

Full Screen

Full Screen

mode.fsm.js

Source:mode.fsm.js Github

copy

Full Screen

1/* Copyright (c) 2017 Red Hat, Inc. */2var inherits = require('inherits');3var fsm = require('../fsm.js');4var move = require('./move.fsm.js');5var group = require('./group.fsm.js');6var rack_fsm = require('./rack.fsm.js');7var site_fsm = require('./site.fsm.js');8function _State () {9}10inherits(_State, fsm._State);11function _Start () {12 this.name = 'Start';13}14inherits(_Start, _State);15var Start = new _Start();16exports.Start = Start;17function _Interface () {18 this.name = 'Interface';19}20inherits(_Interface, _State);21var Interface = new _Interface();22exports.Interface = Interface;23function _Site () {24 this.name = 'Site';25}26inherits(_Site, _State);27var Site = new _Site();28exports.Site = Site;29function _Process () {30 this.name = 'Process';31}32inherits(_Process, _State);33var Process = new _Process();34exports.Process = Process;35function _MultiSite () {36 this.name = 'MultiSite';37}38inherits(_MultiSite, _State);39var MultiSite = new _MultiSite();40exports.MultiSite = MultiSite;41function _Rack () {42 this.name = 'Rack';43}44inherits(_Rack, _State);45var Rack = new _Rack();46exports.Rack = Rack;47function _Device () {48 this.name = 'Device';49}50inherits(_Device, _State);51var Device = new _Device();52exports.Device = Device;53_State.prototype.start = function (controller) {54 controller.scope.current_mode = controller.state.name;55};56_Start.prototype.start = function (controller) {57 controller.scope.app_toolbox_controller.handle_message('Disable', {});58 controller.scope.inventory_toolbox_controller.handle_message('Disable', {});59 controller.scope.rack_toolbox_controller.handle_message('Disable', {});60 controller.scope.site_toolbox_controller.handle_message('Disable', {});61 controller.changeState(Rack);62};63_Start.prototype.start.transitions = ['MultiSite'];64_Interface.prototype.onMouseWheel = function (controller, msg_type, $event) {65 //controller.changeState(Device);66 controller.delegate_channel.send(msg_type, $event);67};68_Interface.prototype.onMouseWheel.transitions = ['Device'];69_Interface.prototype.onScaleChanged = _Interface.prototype.onMouseWheel;70_Site.prototype.start = function (controller) {71 controller.scope.current_mode = controller.state.name;72 controller.scope.rack_toolbox_controller.handle_message('Enable', {});73 controller.scope.rack_controller.changeState(rack_fsm.Ready);74};75_Site.prototype.end = function (controller) {76 controller.scope.rack_toolbox_controller.handle_message('Disable', {});77 controller.scope.rack_controller.changeState(rack_fsm.Disable);78};79_Site.prototype.onMouseWheel = function (controller, msg_type, $event) {80 if (controller.scope.current_scale < 0.1) {81 controller.changeState(MultiSite);82 } else if (controller.scope.current_scale > 0.5) {83 controller.changeState(Rack);84 }85 controller.delegate_channel.send(msg_type, $event);86};87_Site.prototype.onMouseWheel.transitions = ['MultiSite', 'Rack'];88_Site.prototype.onScaleChanged = _Site.prototype.onMouseWheel;89_Process.prototype.onMouseWheel = function (controller, msg_type, $event) {90 controller.delegate_channel.send(msg_type, $event);91 //controller.changeState(Device);92};93_Process.prototype.onMouseWheel.transitions = ['Device'];94_Process.prototype.onScaleChanged = _Process.prototype.onMouseWheel;95_MultiSite.prototype.start = function (controller) {96 controller.scope.current_mode = controller.state.name;97 controller.scope.site_toolbox_controller.handle_message('Enable', {});98 controller.scope.site_controller.changeState(site_fsm.Ready);99};100_MultiSite.prototype.end = function (controller) {101 controller.scope.site_toolbox_controller.handle_message('Disable', {});102 controller.scope.site_controller.changeState(site_fsm.Disable);103};104_MultiSite.prototype.onMouseWheel = function (controller, msg_type, $event) {105 if (controller.scope.current_scale > 0.1) {106 controller.changeState(Site);107 }108 controller.delegate_channel.send(msg_type, $event);109};110_MultiSite.prototype.onMouseWheel.transitions = ['Site'];111_MultiSite.prototype.onScaleChanged = _MultiSite.prototype.onMouseWheel;112_Device.prototype.start = function (controller) {113 controller.scope.current_mode = controller.state.name;114 controller.scope.app_toolbox_controller.handle_message('Enable', {});115};116_Device.prototype.end = function (controller) {117 controller.scope.app_toolbox_controller.handle_message('Disable', {});118};119_Device.prototype.onMouseWheel = function (controller, msg_type, $event) {120 //controller.changeState(Process);121 //controller.changeState(Interface);122 //controller.changeState(Site);123 if (controller.scope.current_scale < 5) {124 controller.changeState(Rack);125 }126 controller.delegate_channel.send(msg_type, $event);127};128_Device.prototype.onMouseWheel.transitions = ['Process', 'Interface', 'Rack'];129_Device.prototype.onScaleChanged = _Device.prototype.onMouseWheel;130_Rack.prototype.start = function (controller) {131 controller.scope.current_mode = controller.state.name;132 controller.scope.inventory_toolbox_controller.handle_message('Enable', {});133 controller.scope.move_controller.changeState(move.Ready);134 controller.scope.group_controller.changeState(group.Ready);135};136_Rack.prototype.end = function (controller) {137 controller.scope.inventory_toolbox_controller.handle_message('Disable', {});138 controller.scope.move_controller.changeState(move.Disable);139 controller.scope.group_controller.changeState(group.Disable);140};141_Rack.prototype.onMouseWheel = function (controller, msg_type, $event) {142 if (controller.scope.current_scale < 0.5) {143 controller.changeState(Site);144 }145 if (controller.scope.current_scale > 5) {146 controller.changeState(Device);147 }148 controller.delegate_channel.send(msg_type, $event);149};150_Rack.prototype.onMouseWheel.transitions = ['Site', 'Device'];...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var win = new redwood.Window();3win.onMouseWheel = function(e) {4 console.log(e);5};6win.show();

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwoodjs');2var canvas = document.getElementById('canvas');3var redwoodCanvas = redwood.createCanvas(canvas);4var rect = redwoodCanvas.createRect({5});6redwoodCanvas.onMouseWheel(function (event) {7 console.log('Mouse Wheel Event');8 console.log(event);9 rect.x += 10;10 rect.y += 10;11 redwoodCanvas.render();12});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var test = function () {3 this.onMouseWheel = function (e) {4 console.log('Mouse wheel event');5 };6};7redwood.register(test);8### onMouseMove(event)9var redwood = require('redwood');10var test = function () {11 this.onMouseMove = function (e) {12 console.log('Mouse move event');13 };14};15redwood.register(test);16### onMouseDown(event)17var redwood = require('redwood');18var test = function () {19 this.onMouseDown = function (e) {20 console.log('Mouse down event');21 };22};23redwood.register(test);24### onMouseUp(event)25var redwood = require('redwood');26var test = function () {27 this.onMouseUp = function (e) {28 console.log('Mouse up event');29 };30};31redwood.register(test);32### onKeyPress(event)33var redwood = require('redwood');34var test = function () {35 this.onKeyPress = function (e) {36 console.log('Key press event');37 };38};39redwood.register(test);40### onKeyUp(event)41var redwood = require('redwood');42var test = function () {43 this.onKeyUp = function (e) {44 console.log('Key up event');45 };46};47redwood.register(test);48### onKeyDown(event)

Full Screen

Using AI Code Generation

copy

Full Screen

1var map;2var mapLayer;3var zoomLevel = 10;4var mouseWheelEvent;5function init() {6 map = new redwood.maps.Map("mapDiv");7 map.addLayer(mapLayer);8 map.centerAndZoom(new redwood.maps.Point(-122.45, 37.75), zoomLevel);9 mouseWheelEvent = new redwood.events.MouseWheelEvent();10 mouseWheelEvent.addMouseWheelHandler(map, onMouseWheel);11}12function onMouseWheel(evt) {13 if (evt.delta > 0) {14 zoomLevel += 1;15 } else {16 zoomLevel -= 1;17 }18 map.centerAndZoom(new redwood.maps.Point(-122.45, 37.75), zoomLevel);19}20function unload() {21 mouseWheelEvent.removeMouseWheelHandler(map, onMouseWheel);22}

Full Screen

Using AI Code Generation

copy

Full Screen

1document.addEventListener("mousewheel", onMouseWheel, false);2document.addEventListener("DOMMouseScroll", onMouseWheel, false);3function onMouseWheel(event) {4 var delta = 0;5 if (!event) /* For IE. */6 event = window.event;7 if (event.wheelDelta) { /* IE/Opera. */8 delta = event.wheelDelta/120;9 } else if (event.detail) { /** Mozilla case. */10 delta = -event.detail/3;11 }12 if (delta)13 handle(delta);14 if (event.preventDefault)15 event.preventDefault();16 event.returnValue = false;17}18function handle(delta) {19 var time = 1000;20 var distance = 300;21 if (delta < 0) {22 $('html, body').stop().animate({23 scrollTop: $(window).scrollTop() + distance24 }, time );25 }26 else {27 $('html, body').stop().animate({28 scrollTop: $(window).scrollTop() - distance29 }, time );30 }31}

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var camera = redwood.camera();3var cameraNode = redwood.getCameraNode();4cameraNode.setPosition(0, 0, 10);5camera.setLookAt(0, 0, 0);6var scene = redwood.scene();7var sphere = scene.createSphere(0, 0, 0, 1);8sphere.setColor(1, 0, 0);9redwood.onMouseWheel(function(e) {10 var zoom = cameraNode.getPosition()[2];11 cameraNode.setPosition(0, 0, zoom + e.delta);12});13redwood.run();

Full Screen

Using AI Code Generation

copy

Full Screen

1var canvas = new redwood(0,0,0,0,0,0);2var canvasChild = new redwood(0,0,0,0,0,0);3canvasChild.setParent(canvas);4canvasChild.setPos(0,0);5canvasChild.setSize(1000,1000);6canvasChild.setFillColor(0,0,0);7canvasChild.setDrawColor(0,0,0);8canvasChild.setDrawWidth(1);9canvas.addChild(canvasChild);10canvas.setPos(0,0);11canvas.setSize(500,500);12canvas.setFillColor(255,255,255);13canvas.setDrawColor(0,0,0);14canvas.setDrawWidth(1);15canvas.setScrollable(true);16function setup() {17 createCanvas(500, 500);18 background(255,255,255);19 canvas.draw();20}21function draw() {22 canvasChild.draw();23}24function mouseWheel(event) {25 canvas.onMouseWheel(event);26}

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run redwood automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful