|
Sab669 posted:
From the MDN entry:
|
# ? May 25, 2017 13:56 |
|
|
# ? May 15, 2024 04:07 |
|
Sab669 posted:I have limited Design knowledge and found myself working on some CSS-related issues on my web application when I came across a lot of syntax I've never seen in CSS before. 1) I think most, if not every, entry there has a "min" and a "max" variant, meaning that "-webkit-device-pixel-ratio" applies the media query (that is, it turns true) when the value reported by the browser is equal to whatever the value on the file. The min and max correspond to the ">" and "<" operators IIRC. 2) That's just an issue with the doc formatting I guess. It also doesn't help that the "-webkit-device-pixel-ratio" is nonstandard. 3) Welcome to Web Dev. I think MDN is still the better place for JS and CSS documentation, though. Maybe this article can explain media queries better than the @media documentation. Space Kablooey fucked around with this message at 14:05 on May 25, 2017 |
# ? May 25, 2017 14:03 |
|
http://kangax.github.io/compat-table/es6/ is good for checking JS feature availability and http://caniuse.com/ is good for CSS (it's less accurate/granular for JS, which is why I prefer kangax's table)
|
# ? May 25, 2017 14:19 |
|
Speaking of, I have some JS code that runs on Chrome, and I have to port it to run in the IE8 runtime. I have a few function calls where I call functions while binding an object (something like this: function(){}.bind(thing)). Is there an equivalent way of calling the the bind on the functions that works in both browsers? Or at least something where the semantics are the same, so I can just do a specific branch to the IE runtime?
Space Kablooey fucked around with this message at 14:31 on May 25, 2017 |
# ? May 25, 2017 14:27 |
|
HardDiskD posted:Speaking of, I have some JS code that runs on Chrome, and I have to port it to run in the IE8 runtime. I have a few function calls where I call functions while binding an object (something like this: function(){}.bind(thing)). Is there an equivalent way of calling the the bind on the functions that works in both browsers? Or at least something where the semantics are the same, so I can just do a specific branch to the IE runtime? I'd just shim it because gently caress supporting that dinosaur with my own spaghetti mess
|
# ? May 25, 2017 14:40 |
|
It worked, thanks!
|
# ? May 25, 2017 15:37 |
|
I am working on a page where the entire contents of a table are generated on page load with a list of dictionaries in Flask/Jinja2. What is the most common way people apply CSS in this situation? My thought is to use jQuery to colorize cells based on their contents.
|
# ? May 25, 2017 17:32 |
|
huhu posted:I am working on a page where the entire contents of a table are generated on page load with a list of dictionaries in Flask/Jinja2. What is the most common way people apply CSS in this situation? My thought is to use jQuery to colorize cells based on their contents. Why wouldn't you use CSS classes and/or id's as you generate the HTML. I see literally no need for JavaScript in the example you're describing.
|
# ? May 25, 2017 17:35 |
|
The Fool posted:Why wouldn't you use CSS classes and/or id's as you generate the HTML. Specific columns need different background colors and specific cells are colored based on their value. I am already using just CSS to set a base color for all TH and then alternating background colors for odd/even rows.
|
# ? May 25, 2017 17:44 |
|
huhu posted:Specific columns need different background colors and specific cells are colored based on their value. I am already using just CSS to set a base color for all TH and then alternating background colors for odd/even rows. I'm still unclear why you can't do it while you're generating the HTML. You know what the value of the cells are when you're "in" the template, so create the styles/classes/ids while you're generating the rest of the HTML.
|
# ? May 25, 2017 18:12 |
|
huhu posted:Specific columns need different background colors and specific cells are colored based on their value. I am already using just CSS to set a base color for all TH and then alternating background colors for odd/even rows. What they are saying is that using jQuery to select cells by value is an extra step, because you've already iterated through each cell and had its value in-hand when you were generating the html. You can put whatever logic you would apply with jQuery into you html generation process. Otherwise you're essentially writing everything, forgetting what you wrote, and goingnback through it again. And jQuery is powerful, but a large number of class selectors is much slower than... not doing that.
|
# ? May 25, 2017 18:19 |
|
Snak posted:What they are saying is that using jQuery to select cells by value is an extra step, because you've already iterated through each cell and had its value in-hand when you were generating the html. You can put whatever logic you would apply with jQuery into you html generation process. Ah ok, I see now. Thanks.
|
# ? May 25, 2017 19:14 |
|
I don't know much about Jinja, but if it were Django, I'd consider the Javascript approach; a way you could do it on the backend in Django's rigid template system is to pass a separate dict with keys associated with your table cell, and CSS classes, or style strings as their values; or mesh it into your existing data structure. The javascript approach would iterate through the cells, perhaps with something like this; The backend solution I described can be more confusing, since it may involve passing an additional data structure to the template, or altering an abstract data structure with UI-specific code.JavaScript code:
JavaScript code:
Dominoes fucked around with this message at 20:14 on May 25, 2017 |
# ? May 25, 2017 20:09 |
|
var tbody = document.createElement("tbody"); tbody.innerHTML = "<tr class='odd'></></tr><tr class='nod'></></tr><tr class='odd'></></tr><tr class='nod'></></tr>"; document.getElementById("mytable").appendChild(tbody);
|
# ? May 25, 2017 20:14 |
|
I'm working on an app in React-Native and I am trying to render a component with children. If I use the component directly it functions 100% as expected, but if I return it from a condition statement it doesn't render children. Can someone please tell me what is wrong. I've omitted styling, because it's not part of the problem. Button.js code:
App.js code:
App.js code:
Am I doing something wrong? ModeSix fucked around with this message at 20:52 on May 25, 2017 |
# ? May 25, 2017 20:48 |
|
ModeSix posted:I'm working on an app in React-Native and I am trying to render a component with children. If I use the component directly it functions 100% as expected, but if I return it from a condition statement it doesn't render children. A quick glance looks fine, but maybe it's something somewhere else in the code you've omitted? The only possibility I see from what you have is the binding of this, but that shouldn't be a problem there.
|
# ? May 25, 2017 20:53 |
|
Lumpy posted:A quick glance looks fine, but maybe it's something somewhere else in the code you've omitted? The only possibility I see from what you have is the binding of this, but that shouldn't be a problem there. Alright, here's the whole thing: App.js - https://pastebin.com/PqKnTxjK Button.js - https://pastebin.com/EnXG9cJv I assume you don't need to see everything else such as the login form and spinner components. ModeSix fucked around with this message at 20:59 on May 25, 2017 |
# ? May 25, 2017 20:56 |
|
Try this:JavaScript code:
(Also have a think about whether the boolean logic in renderContent suits a switch statement.)
|
# ? May 25, 2017 21:48 |
|
The logic is working fine. It switches correctly it's just not rendering the children in the button. Ie: Log out doesn't display inside the button. The children are empty. ModeSix fucked around with this message at 13:22 on May 26, 2017 |
# ? May 26, 2017 00:41 |
|
modesix, your example works just fine for me, but I'm not using react native. ynohtna posted:Try this: You may want to follow your own advice, and then have a think about how this post is entirely unhelpful
|
# ? May 26, 2017 17:00 |
|
Tei posted:var tbody = document.createElement("tbody"); I am going to quote me, because this humble post contains many hours of experience in it. If you are creating some sort of single page web app, and when the users open the page you generated a lot of HTML and then insert in the page. DON'T directly change the DOM tree in small incremental changes, like most code examples do on the Internet, or seems the straightforward way. Every change to the DOM tree is a very heavy weight operation. Multiple changes to it will result on some superslughish reaction times. If is truly a massive table you are inserting, it may be 12 long seconds where the whole browser/tab is completely frozen and to the user will appear exactly like a crashed tab/browser. Instead of doing changes to the tree. You can do changes to a tree in memory. It can be a simple node. It can be a clone'd version of the stuff in the page. Then insert / replace this node to what is on the page. So if you are using jquery or vanilla js, do things the way I describe. Edit: Of course, those clever kids and their angular and react frameworks don't need to care about any of this. They framework use other and smart strategies for working with the DOM tree. Tei fucked around with this message at 17:14 on May 26, 2017 |
# ? May 26, 2017 17:11 |
|
This is true, but the OP mentioned that the table is being generated server-side.
|
# ? May 26, 2017 19:31 |
|
ROFLburger posted:modesix, your example works just fine for me, but I'm not using react native. Something odd is happening with my reusable components. I've noticed they work sometimes and not others and they are being implemented in exactly the same way each time. Even when copying components to a new project they function sometimes and not others. I think there may be some underlying problem in my development environment, though god knows what because I've never had a problem with anything else like this, except when using react-native. For example my header component works fine in one project but not in another. If I rewrite it from scratch the exact same way it was originally written it will function (usually).
|
# ? May 27, 2017 14:41 |
|
My page's body has a whole bunch of extra flab on the right side if viewed portrait on mobile. I just want it to zoom to the content's width automatically, and not scroll horizontally. All my script is on the front page: http://www.mysterysystem.com Many thanks edit: I edited the view port: <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> In portrait now on my iPhone 6s plus the content goes beyond the screen width. Doesn't seem to do what it's told there.. edit 2! Looks like it is working better for mobile. It was the canvas and controls that was a problem. LP0 ON FIRE fucked around with this message at 23:20 on May 27, 2017 |
# ? May 27, 2017 17:01 |
|
We've been discussing something in the the coding horrors thread starting here which is apropos to this thread: How Medical Tech Gave a Patient a Massive Overdose
|
# ? May 29, 2017 17:41 |
|
Thermopyle posted:We've been discussing something in the the coding horrors thread starting here which is apropos to this thread: How Medical Tech Gave a Patient a Massive Overdose Such a good read. Thanks for that
|
# ? May 31, 2017 05:55 |
|
So, this is a really noob question I'm sure. I don't know anything at all about animation and transformation. I mean, I've used jquerys fadein/out and thats about it. I have a small form that I'd like to animate and transform into a plain card presenting its info when its filled out. If possible, what do I need to do to animate/transition from a smattering of various <input> types to some styled HTML...maybe some <li> elements or whatever with some styling on them? I'm not only interested in learning an easy way to do this task, but I'd also like to learn more about the subject in general...
|
# ? Jun 1, 2017 00:59 |
|
One of the key things to understand about animating in websites is there's no one way to do it. - CSS transitions - CSS animations - JavaScript driven animations of CSS properties - SVG animations (also usually driven by CSS & JS) When you animate, usually the first thing you determine your main states, so say you know your start state, and your end state. Can you style both those states using pure CSS? Well then you're in CSS transition town most likely. All you need is a container class that switches between the two states, and then you can put transition rules on all the properties you want to animate. From there it gets more complicated, you may have to calculate animations using JavaScript, there are good tools out there like Velocity js. Going from there though, you have green sock animation platform, which is best suited for big set piece animations but I've never really used it. Regardless of the method used though, I think it always comes back to understanding your 'keyframes' of state, what it looks like and what CSS/HTML was required to make it look like that, and then efficiently coding the animation between those states. Efficient means preferring non layout transitions. Opacity and transforms are 'layer' based and that means hardware can do a great job with them. Colour operations are 'paint' and are a shade more expensive. Height, width, fonts, etc are all 'layout' based and are the most expensive transitions to execute, and as such should be limited where possible, but it depends on the context. Desktops can hold their frames way better than mobile devices, so you should really limit mobile stuff to 'layer' operations as far as practicable if you want to hold your 60 fps or whatever. This also means understanding where your animation falls in relationship to the app 'thinking', maybe you defer the actual 'post' until the animation is done, it always depends on circumstance. Or progressive animation can hide bits of your app that are slow because an Ajax request is behind it. I guess I'm saying there's lots to learn but the important thing is to start with some basics I think, like the aforementioned CSS transitions, because there is no silver bullet animation technique. Maluco Marinero fucked around with this message at 07:20 on Jun 1, 2017 |
# ? Jun 1, 2017 03:38 |
|
Thermopyle posted:So, this is a really noob question I'm sure. CSS Transforms and Animations don't allow you to change one set of markup into another. That would be way outside the scope of CSS. It just lets you change the appearance of your markup. You'll need to use some really nasty JS, probably something like React, to do what you're suggesting here. Saying that, if it's really just a different look=-and-feel you're going for, you could keep the markup as-is and use CSS to make it look like a card with a list of items on it.
|
# ? Jun 1, 2017 09:26 |
|
This is on a business partner's site, not ours, but I was still curious what you guys think. Their server basically serves everything up as a GUID named jpg, regardless of what format the file actually. I downloaded some product photos to edit, and I couldn't open them in Photoshop until I changed the extension to PNG (I double checked the file header to figure this out). The browser seems to know what to do regardless, but the actual mime type being passed is image/jpeg instead of image/png. Is this going to cause problems for them? I'm not sure if it's something I should warn them about or not.
|
# ? Jun 1, 2017 23:39 |
|
Scaramouche posted:This is on a business partner's site, not ours, but I was still curious what you guys think. As I've written something that does basically this, they probably did not think to store the mimetype in the database they serve the images up from, and so their API just uses a fixed image/jpeg. Might be worth mentioning if it was truly overlooked.
|
# ? Jun 2, 2017 01:35 |
|
I hope this isn't an inappropriate request here, but I'm having trouble with my simple jQuery script running on my iOS devices (both Chrome and Safari). The script controls the behavior of a navbar (#traveler) that appears when a user begins to scroll up when they are far down the page, but disappears when a user continues to scroll down, or when the original navbar at the top of the page is visible. code:
(Also, I can link to my codepen if that's easier.)
|
# ? Jun 3, 2017 17:49 |
|
fsif posted:I hope this isn't an inappropriate request here, but I'm having trouble with my simple jQuery script running on my iOS devices (both Chrome and Safari). Googling "iOS window scroll jQuery" showed me many solutions to this common problem. Here's a couple: https://stackoverflow.com/questions/2863547/javascript-scroll-event-for-iphone-ipad https://stackoverflow.com/questions/18753367/jquery-live-scroll-event-on-mobile-work-around
|
# ? Jun 3, 2017 21:23 |
|
God, thank you! Everything I found was talking about problems when using body as a selector, so I was on the wrong track.
|
# ? Jun 3, 2017 21:39 |
|
fsif posted:God, thank you! Everything I found was talking about problems when using body as a selector, so I was on the wrong track. No worries! I have that happen all the time, I find 293812321 solutions for a slightly similar but not quite my problem, then someone else says "why didn't you google X?" It's like seeing typos... you can never find your own, but a second set of eyes can do it instantly.
|
# ? Jun 3, 2017 21:49 |
|
Haha yeah sometimes the solution is just in knowing what to Google.
|
# ? Jun 5, 2017 08:45 |
|
I wonder if theres a pure CSS solution to what you want to do. Considering mobile devices are mentioned, they usually hate anything Jquery + scroll related with a passion of 1000 suns. You can do this: Check a website that have this effect, inspect the code to see how is called. Then use that term to google "<foo> pure CSS solution" that foo thing.
|
# ? Jun 5, 2017 13:28 |
|
I need to find some lightweight solution to implement a sort of CSM that non-tech people can easily edit content on multiple static websites and then push onto S3. Basically, right now the whole workflow is a bit daft and slow, sometime ago someone decided to use jekylll as a quick static site generator and the content changes would be requested to anyone with time and some kownledge of the hellish folder structure and update it; so yeah, I want to change that into something more lean and efficient. Any suggestions? I've been looking into keystone.js but it might be overkill.
|
# ? Jun 5, 2017 16:35 |
|
Honest Thief posted:I need to find some lightweight solution to implement a sort of CSM that non-tech people can easily edit content on multiple static websites and then push onto S3.
|
# ? Jun 5, 2017 16:41 |
|
|
# ? May 15, 2024 04:07 |
|
Maluco Marinero posted:animation stuff Thanks for this high level overview, it's helpful! Sergeant Rock posted:CSS Transforms and Animations don't allow you to change one set of markup into another. That would be way outside the scope of CSS. It just lets you change the appearance of your markup. You'll need to use some really nasty JS, probably something like React, to do what you're suggesting here. Yeah, just to be clear I'm not so clueless that I thought CSS could change markup! I know how to change markup in a dozen different ways...it's really making that change look good that I'm thinking about. It's a pretty harsh experience for the user for the markup to just change in like 0 ms. In the ideal world I'd have the knowledge and skills to implement this idea that I have in my head: When user clicked "add" button on form, the data on the form would animate/move from the form over into a card located in a tray-like area on the side of the page while leaving the form in-place for adding a new item. Kind of like how in several operating systems when you minimize/restore a window it animates into/out-of its icon the dock/taskbar. Currently I fade the form data out, and fade the card in. I'd really like to make the connection between the form and the card more explicit with the effect I describe above... Also, when I asked in this thread about alternatives to bootstrap someone recommended SemanticUI. Thanks for that recommendation. This is nice and already has a decent React implementation...and its maintained by the SemanticUI project itself unlike the various React/Bootstrap integrations out there. Thermopyle fucked around with this message at 17:43 on Jun 5, 2017 |
# ? Jun 5, 2017 17:41 |