0

how to make automatic scrolling arrow function to operate websites ?

i think you know what i mean

16th Oct 2017, 3:53 PM
Ali Hussain Dhuniya
Ali Hussain Dhuniya - avatar
1 Antwort
+ 6
Did you mean "scroll feature on mouse hovering an arrow button/element"? or a "arrow function" to handle scroll through JS? In 1st case, you must be aware that handling "hover" effects will only work on non-touch devices ^^ Anyway, this code handle it without "automatic scroll", but "on click/touch": just use mouseenter, mouseover and mouseout events instead/in addition: https://code.sololearn.com/WE9K9q7LLgRt/?ref=app In 2nd case, "arrow function" are quite same as "normal (anonymized) function" (there's some subtle differences between them) but shorthanded: function f1(arg) { /* code */ } // default function declaration (automatically declare a 'f1' variable) var f2 = function (arg) { /* code */ }; // assigned unnamed function declaration (variable name is assigned explicitly with an anonymized function) var f3 = (arg) => { /* code */ }; // "arrow" shorthanded function declaration (always anonymized/without name reference, so reference need to be used immediatly and/or stored explicitly) "Normal" functions can also be declared/builded using the Function() constructor. "Arrow" functions can also be written with parenthesis (rounded brackets) instead of curly brackets, in case of only one statement: var f4 = (arg) => { return arg+42; }; // same as: var f5 = (arg) => ( arg+42 ); // only one statement doesn't implies only one instruction: semi-colon are not allowed (separating statements) but coma can be use to do many instructions in one statement: last (most right) is used as returned value: var f6 = (arg) => ( console.log(arg), arg+42 ); So, "arrow" functions are just another way of writing/declaring functions: check this 2nd (very) shorter JS code (10 code lines against more than 100 ;P) handling scroll through JS, but not using JS "arrow" functions: https://code.sololearn.com/WO4ZES0iI5mE/?ref=app ... and just change way of writing the single function used as event listener by replacing only 1st line of code: //window.onscroll=function() { window.onscroll = () => {
17th Oct 2017, 5:11 PM
visph
visph - avatar