I am new to javascript / jQuery, however I am working hard to understand what I am doing. I was inspired by the diesel site . On this site, data attributes are used for text blocks on the main page. data-color . I want to perform this function on my site . The ability to change the color of each block on the record, since the user scrolls down the page, it starts in different ways.
I came here for help since I have not seen any tutorial on the functionality that I am trying to achieve. Does anyone know how to do this? I believe that this would be useful for those who want to perform the same or similar functionality.
getColorMod: function(color, val) { var hexToRgb = function(hex) { var result = /^#?([af\d]{2})([af\d]{2})([af\d]{2})$/i.exec(hex); return result ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)] : false; } var array = hexToRgb(color), r = parseFloat(array[0] + val), g = parseFloat(array[1] + val), b = parseFloat(array[2] + val), rgb = array ? { r: r >= 250 ? 200 : r, g: g >= 250 ? 200 : g, b: b >= 250 ? 200 : b } : false; return 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')'; },
source share