Theread-only style property of the HTMLElement returns the inline style of an element in the form of a live CSSStyleDeclaration object that contains a list of all styles properties for that element with values assigned only for the attributes that are defined in the element's inline style attribute.
This property is read-only, meaning it is not possible to assign a CSSStyleDeclaration object to it. Nevertheless, it is possible to set an inline style by assigning a string directly to the style property. In this case the string is forwarded to CSSStyleDeclaration.cssText. Using style in this manner will completely overwrite all inline styles on the element.
Therefore, to add specific styles to an element without altering other style values, it is generally preferable to set individual properties on the CSSStyleDeclaration object. For example, you can write element.style.backgroundColor = "red".
Note font-weight is not listed as a value for elementStyle as it is not defined within the style attribute of the element itself. Rather, it is inherited from the definition on its parent. Also note that the shorthand border-top property, defined in the style attribute, is not listed directly. Rather, it is replaced by the three corresponding longhand properties (border-top-color, border-top-style, and border-top-width).
Therefore, to add specific styles to an element without altering other style values, it is generally preferable to set individual properties on the CSSStyleDeclaration object. For example, you can write element.style.backgroundColor = \"red\".
This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax.
The reason you would use GSAP set() versus element.style is so GSAP can keep track of what you are setting. If you use element.style, than you are updating the DOM with a CSS style change on an element outside of GSAP. So in your case you can use the GSAP set method so GSAP can keep track of your CSS changes. Now that doesn't mean you have to use GSAP set(), but there are some benefit to using set() over element.style. Using element.style is likely faster, but if it was me I would opt for GSAP being always in the loop on what CSS properties you change. Im sure others here might opt for one over the other. But you can test each one and see what works best for your project.
Using set() creates an actual tween with no duration. A tween by nature needs to read current values of the properties you are animating (or setting) and then also record the ending values. Also a tween is a javascript object with quite a few methods and properties.
With element.style you have a direct path to changing a value with no additional memory or cpu overhead. element.style technically is less work than using set(). Whether or not you would ever notice any difference really depends on how you are using it and I suspect you'd only find a significant difference if you were doing hundreds (or thousands) of sets() vs hundreds of element.style.
Yep, @Jonathan and @Carl are correct. Just to be add to what Jonathan said, it's particularly helpful to set transform-related values via GSAP rather than directly or via CSS because future animations can be faster and more accurate. GSAP caches the transform-related values and can skip parsing the matrix() or matrix3d() values that are reported by the browser which are inherently ambiguous (a rotation of 0, 360, 720, etc. result in the same matrix, and various other values combinations could be equally valid so things can get very imprecise). If all you're doing is setting values that are not transform-related, it's fine to set them directly. Most people find it's "safest" to go through GSAP since it solves so many browser inconsistencies, especially with transforms.
Thanks will check those out:) What I am doing in this particular case is basically together with a mousemove event. I get the mouse coordinates with the event and then animate stuff with requestAnimationFrame. But in general I use requestAnimationFrame with most event that are fired a lot... mousemove, scrolll, touch events and so on. But maybe ModfiersPlugin might be able to replace requestAnimationFrame in some of these cases? Will check=)
But in general I use requestAnimationFrame with most event that are fired a lot... mousemove, scrolll, touch events and so on. But maybe ModfiersPlugin might be able to replace requestAnimationFrame in some of these cases?
Obsidian looks like it is purpose built pursuing everything I had hoped for and which I have felt was missing in markdown authoring for the last decade. I have seen nothing that is so close to patterns I use, other than plugin-enabled features within VsCode.
I do extensive work in VsCode, including authoring extensions. However, for markdown knowledge base authoring Obsidian is purpose built and tailored. Making it an ideal choice if I can learn/enable the capabilities I am looking for. I happen to have dev-engineering experience with MarkdownHTML, code generators, languages and tools, and related practices and patterns similar to the ideas expressed embodied in Obsidian as well as the Zettelkasten references.
For custom elements the shadow DOM CSS is fully nested and encapsulated within the Custom Elements node subtree. In other words, locality of reference placement which is not code-design-tool constrained by the HTML standard of style element placement in the head.
The deeper thing I am exploring in Obsidian is what are its current capabilities for aggregation and composition of content and pages built from a markdown/YAML/HTML core. I am trying to see if I can use it for the toolsets and publishing patterns I already have for managed site workspaces whose content and structure is primarily described in wiki/markdown style.
With regard to interleaved HTML and markdown, the objective is to allow an html element to be used as a CSS (possibly JS) managed container but have the majority of its sub-content be authored in markdown. Which happens to include micro-web-service api capabilties.
Now, the real benefit of using class to style an element is to target multiple elements that have the matching class attribute. For example, if there are 2 buttons on a webpage and they both look similar in style but only differ in size, then we can use a common class to give them common styles and a unique class for each button to give them different size values.
Using the above defined .button class as a common style for both buttons, and using .large and .small class attributes to give them different sizes, we can achieve the look we want without duplicating our code.
Element styles can be specific to one particular header in its unique application and that should depend on exactly where we place the class call but it would not work here for me. I also tried a different color by adding the header
Your code is correct. You have defined a class of text but you need to state the name its stored under. In this example Style is the name your code will be available under and it will apply only to the elements which call for it, so lets do that.
If I apply only those settings with the disabled element state, I see the expected background color. I don't see the border color because there's no border in use by the button. If you're not seeing the expected values, you're likely running into contention with another class you've applied. Examine the Styles tab of the Developer tools to see what value is being used instead - as well as which rule is causing it to be applied.
So, interestingly enough, when I uncheck the "border:" check box in the Chrome developer tools, the border comes back and now I can see where it is the proper black color. I'm not super familiar with web development, but I'm assuming where it says "var(--border--disabled);" after it is disabling all borders for some reason.
You can see that the border colors applied here are being overwritten later on, but since the border has no width you'll never see it. Your style class must override the border width and border type in order to display the border in this scenario.
Screenshot 2024-04-22 at 11.16.10 AM636580 24.5 KB
Even when I remove the binding on that attribute, it still stays at the specified static value on the attribute. It's only when I delete the attribute from the PROPS category, does the style class have effect and change the background color.
I can promise you that will do it, because "inline" values take precedence. Binding or not, if you've specified any color other than the default "empty string" value that's the value that will be used. Setting a property value is how you apply a value and ignore any applied CSS.
Samuel - a design tip: don't use underline in your HMIs. It's never1 used by professional graphic designers. Check in books, magazines, advertising and professionally designed GUI applications such as Windows, MacOS, Linux etc., except for hyperlinks or to indicate an Alt-hotkey combination. Underlining distorts the shape of the word and cuts through descenders in lowercase letters.
3a8082e126