Setting z-index and transform?












0















I'm working on an image gallery, when the user clicks on a photo in the gallery the photo will do a 3D animation to the center of the screen, something like this:



const style = this.state.expanded ? {
transform: 'translate3d(' + this.state.xOffset + 'px, ' + this.state.yOffset + 'px, 10em) scale(2)',
transition: theme.transitions.create('transform')
} : {
transform: 'translate3d(0px, 0px, 0px)',
transition: theme.transitions.create('transform')
}


That style is applied to every image in the gallery, something like:



//react-virtualized grid of: <div ref={this.divElement} style={style as any}> {...etc}</div>


This works fine except 'zIndex' is not respected when transform is applied. I've tried setting a z offset to the translate3D to no avail.



All I really want is for the expanded image to render last and on top of all the other cards.



Here's the root react virtualized component:



class MasonryComponent extends React.Component<IMasonryProps, IMasonryState>
{
state = {
columns: 3
}
_cellPositioner: Positioner | undefined = undefined

// Default sizes help Masonry decide how many images to batch-measure
cache = new CellMeasurerCache({
defaultHeight,
defaultWidth,
fixedWidth: true
});

columnWidth = () => {
const { columnWidth, width } = this.props;

// const newW = width > columnWidth ? columnWidth : width;

return width > columnWidth ? columnWidth : width;
}

_initCellPositioner = () => {
const columnWidth = this.columnWidth()
if (typeof this._cellPositioner === 'undefined') {
this._cellPositioner = createMasonryCellPositioner({
cellMeasurerCache: this.cache,
columnCount: this.state.columns,
columnWidth,
spacer: gutter,
});
}
}

componentWillReceiveProps(nextProps: IMasonryProps) {
if (JSON.stringify(nextProps.items) !== JSON.stringify(this.props.items)) {
this._masonry.current!.clearCellPositions();

this.cache.clearAll();
this.cellPositioner(this.props.width);
this._masonry.current!.clearCellPositions();
}
}

cellPositioner = (width: number): Positioner => {
const columnWidth = this.columnWidth()
const columns = Math.floor(width / columnWidth);
if (this.state.columns != columns)
this.setState({ columns: columns });

this._cellPositioner!.reset({
columnCount: columns,
columnWidth: columnWidth,
spacer: gutter
})

if (this._masonry.current)
this._masonry.current.recomputeCellPositions();


return this._cellPositioner!
}
_masonry = React.createRef<Masonry>()

cellRenderer = ({ index, key, parent, style }: any) => {
const props = this.props;
if (!props.items[index])
return <div>404</div>

const item = props.items[index];
let customRender = props.customRender;

const size = this.props.imageSizeResolve(item);
const columnWidth = this.columnWidth()
return (
<CellMeasurer cache={this.cache} index={index} key={key} parent={parent}>
{customRender ? customRender(item, style, columnWidth) :
<div style={style}>
<img
src={item.url}
style={{
width: columnWidth,
height: columnWidth / size.width * size.height
}}
/>
</div>}
</CellMeasurer>
);
}
public render() {
const props = this.props;

this._initCellPositioner();

const columnWidth = this.columnWidth()
let paddingLeft = props.width < columnWidth ? 0 : (props.width - (columnWidth + gutter) * this.state.columns) / 2
if (paddingLeft < 0) {
paddingLeft = 0;
}
return (
<Masonry
style={{
paddingLeft
}}
overscanByPixels={1080}
ref={this._masonry}
autoHeight={false}
cellCount={props.items ? props.items.length : 0}
cellMeasurerCache={this.cache}
cellPositioner={this.cellPositioner(props.width)}
cellRenderer={this.cellRenderer}
height={props.height}
width={props.width}
/>
);
}
};


Anyway to accomplish this?










share|improve this question

























  • can you attach rendered DOM part that holds it?

    – mkbctrl
    Dec 29 '18 at 9:00











  • @mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

    – tweetypi
    Dec 29 '18 at 9:02






  • 1





    oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

    – mkbctrl
    Dec 29 '18 at 9:17











  • take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

    – mkbctrl
    Dec 29 '18 at 9:20











  • Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

    – mkbctrl
    Dec 29 '18 at 9:25
















0















I'm working on an image gallery, when the user clicks on a photo in the gallery the photo will do a 3D animation to the center of the screen, something like this:



const style = this.state.expanded ? {
transform: 'translate3d(' + this.state.xOffset + 'px, ' + this.state.yOffset + 'px, 10em) scale(2)',
transition: theme.transitions.create('transform')
} : {
transform: 'translate3d(0px, 0px, 0px)',
transition: theme.transitions.create('transform')
}


That style is applied to every image in the gallery, something like:



//react-virtualized grid of: <div ref={this.divElement} style={style as any}> {...etc}</div>


This works fine except 'zIndex' is not respected when transform is applied. I've tried setting a z offset to the translate3D to no avail.



All I really want is for the expanded image to render last and on top of all the other cards.



Here's the root react virtualized component:



class MasonryComponent extends React.Component<IMasonryProps, IMasonryState>
{
state = {
columns: 3
}
_cellPositioner: Positioner | undefined = undefined

// Default sizes help Masonry decide how many images to batch-measure
cache = new CellMeasurerCache({
defaultHeight,
defaultWidth,
fixedWidth: true
});

columnWidth = () => {
const { columnWidth, width } = this.props;

// const newW = width > columnWidth ? columnWidth : width;

return width > columnWidth ? columnWidth : width;
}

_initCellPositioner = () => {
const columnWidth = this.columnWidth()
if (typeof this._cellPositioner === 'undefined') {
this._cellPositioner = createMasonryCellPositioner({
cellMeasurerCache: this.cache,
columnCount: this.state.columns,
columnWidth,
spacer: gutter,
});
}
}

componentWillReceiveProps(nextProps: IMasonryProps) {
if (JSON.stringify(nextProps.items) !== JSON.stringify(this.props.items)) {
this._masonry.current!.clearCellPositions();

this.cache.clearAll();
this.cellPositioner(this.props.width);
this._masonry.current!.clearCellPositions();
}
}

cellPositioner = (width: number): Positioner => {
const columnWidth = this.columnWidth()
const columns = Math.floor(width / columnWidth);
if (this.state.columns != columns)
this.setState({ columns: columns });

this._cellPositioner!.reset({
columnCount: columns,
columnWidth: columnWidth,
spacer: gutter
})

if (this._masonry.current)
this._masonry.current.recomputeCellPositions();


return this._cellPositioner!
}
_masonry = React.createRef<Masonry>()

cellRenderer = ({ index, key, parent, style }: any) => {
const props = this.props;
if (!props.items[index])
return <div>404</div>

const item = props.items[index];
let customRender = props.customRender;

const size = this.props.imageSizeResolve(item);
const columnWidth = this.columnWidth()
return (
<CellMeasurer cache={this.cache} index={index} key={key} parent={parent}>
{customRender ? customRender(item, style, columnWidth) :
<div style={style}>
<img
src={item.url}
style={{
width: columnWidth,
height: columnWidth / size.width * size.height
}}
/>
</div>}
</CellMeasurer>
);
}
public render() {
const props = this.props;

this._initCellPositioner();

const columnWidth = this.columnWidth()
let paddingLeft = props.width < columnWidth ? 0 : (props.width - (columnWidth + gutter) * this.state.columns) / 2
if (paddingLeft < 0) {
paddingLeft = 0;
}
return (
<Masonry
style={{
paddingLeft
}}
overscanByPixels={1080}
ref={this._masonry}
autoHeight={false}
cellCount={props.items ? props.items.length : 0}
cellMeasurerCache={this.cache}
cellPositioner={this.cellPositioner(props.width)}
cellRenderer={this.cellRenderer}
height={props.height}
width={props.width}
/>
);
}
};


Anyway to accomplish this?










share|improve this question

























  • can you attach rendered DOM part that holds it?

    – mkbctrl
    Dec 29 '18 at 9:00











  • @mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

    – tweetypi
    Dec 29 '18 at 9:02






  • 1





    oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

    – mkbctrl
    Dec 29 '18 at 9:17











  • take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

    – mkbctrl
    Dec 29 '18 at 9:20











  • Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

    – mkbctrl
    Dec 29 '18 at 9:25














0












0








0








I'm working on an image gallery, when the user clicks on a photo in the gallery the photo will do a 3D animation to the center of the screen, something like this:



const style = this.state.expanded ? {
transform: 'translate3d(' + this.state.xOffset + 'px, ' + this.state.yOffset + 'px, 10em) scale(2)',
transition: theme.transitions.create('transform')
} : {
transform: 'translate3d(0px, 0px, 0px)',
transition: theme.transitions.create('transform')
}


That style is applied to every image in the gallery, something like:



//react-virtualized grid of: <div ref={this.divElement} style={style as any}> {...etc}</div>


This works fine except 'zIndex' is not respected when transform is applied. I've tried setting a z offset to the translate3D to no avail.



All I really want is for the expanded image to render last and on top of all the other cards.



Here's the root react virtualized component:



class MasonryComponent extends React.Component<IMasonryProps, IMasonryState>
{
state = {
columns: 3
}
_cellPositioner: Positioner | undefined = undefined

// Default sizes help Masonry decide how many images to batch-measure
cache = new CellMeasurerCache({
defaultHeight,
defaultWidth,
fixedWidth: true
});

columnWidth = () => {
const { columnWidth, width } = this.props;

// const newW = width > columnWidth ? columnWidth : width;

return width > columnWidth ? columnWidth : width;
}

_initCellPositioner = () => {
const columnWidth = this.columnWidth()
if (typeof this._cellPositioner === 'undefined') {
this._cellPositioner = createMasonryCellPositioner({
cellMeasurerCache: this.cache,
columnCount: this.state.columns,
columnWidth,
spacer: gutter,
});
}
}

componentWillReceiveProps(nextProps: IMasonryProps) {
if (JSON.stringify(nextProps.items) !== JSON.stringify(this.props.items)) {
this._masonry.current!.clearCellPositions();

this.cache.clearAll();
this.cellPositioner(this.props.width);
this._masonry.current!.clearCellPositions();
}
}

cellPositioner = (width: number): Positioner => {
const columnWidth = this.columnWidth()
const columns = Math.floor(width / columnWidth);
if (this.state.columns != columns)
this.setState({ columns: columns });

this._cellPositioner!.reset({
columnCount: columns,
columnWidth: columnWidth,
spacer: gutter
})

if (this._masonry.current)
this._masonry.current.recomputeCellPositions();


return this._cellPositioner!
}
_masonry = React.createRef<Masonry>()

cellRenderer = ({ index, key, parent, style }: any) => {
const props = this.props;
if (!props.items[index])
return <div>404</div>

const item = props.items[index];
let customRender = props.customRender;

const size = this.props.imageSizeResolve(item);
const columnWidth = this.columnWidth()
return (
<CellMeasurer cache={this.cache} index={index} key={key} parent={parent}>
{customRender ? customRender(item, style, columnWidth) :
<div style={style}>
<img
src={item.url}
style={{
width: columnWidth,
height: columnWidth / size.width * size.height
}}
/>
</div>}
</CellMeasurer>
);
}
public render() {
const props = this.props;

this._initCellPositioner();

const columnWidth = this.columnWidth()
let paddingLeft = props.width < columnWidth ? 0 : (props.width - (columnWidth + gutter) * this.state.columns) / 2
if (paddingLeft < 0) {
paddingLeft = 0;
}
return (
<Masonry
style={{
paddingLeft
}}
overscanByPixels={1080}
ref={this._masonry}
autoHeight={false}
cellCount={props.items ? props.items.length : 0}
cellMeasurerCache={this.cache}
cellPositioner={this.cellPositioner(props.width)}
cellRenderer={this.cellRenderer}
height={props.height}
width={props.width}
/>
);
}
};


Anyway to accomplish this?










share|improve this question
















I'm working on an image gallery, when the user clicks on a photo in the gallery the photo will do a 3D animation to the center of the screen, something like this:



const style = this.state.expanded ? {
transform: 'translate3d(' + this.state.xOffset + 'px, ' + this.state.yOffset + 'px, 10em) scale(2)',
transition: theme.transitions.create('transform')
} : {
transform: 'translate3d(0px, 0px, 0px)',
transition: theme.transitions.create('transform')
}


That style is applied to every image in the gallery, something like:



//react-virtualized grid of: <div ref={this.divElement} style={style as any}> {...etc}</div>


This works fine except 'zIndex' is not respected when transform is applied. I've tried setting a z offset to the translate3D to no avail.



All I really want is for the expanded image to render last and on top of all the other cards.



Here's the root react virtualized component:



class MasonryComponent extends React.Component<IMasonryProps, IMasonryState>
{
state = {
columns: 3
}
_cellPositioner: Positioner | undefined = undefined

// Default sizes help Masonry decide how many images to batch-measure
cache = new CellMeasurerCache({
defaultHeight,
defaultWidth,
fixedWidth: true
});

columnWidth = () => {
const { columnWidth, width } = this.props;

// const newW = width > columnWidth ? columnWidth : width;

return width > columnWidth ? columnWidth : width;
}

_initCellPositioner = () => {
const columnWidth = this.columnWidth()
if (typeof this._cellPositioner === 'undefined') {
this._cellPositioner = createMasonryCellPositioner({
cellMeasurerCache: this.cache,
columnCount: this.state.columns,
columnWidth,
spacer: gutter,
});
}
}

componentWillReceiveProps(nextProps: IMasonryProps) {
if (JSON.stringify(nextProps.items) !== JSON.stringify(this.props.items)) {
this._masonry.current!.clearCellPositions();

this.cache.clearAll();
this.cellPositioner(this.props.width);
this._masonry.current!.clearCellPositions();
}
}

cellPositioner = (width: number): Positioner => {
const columnWidth = this.columnWidth()
const columns = Math.floor(width / columnWidth);
if (this.state.columns != columns)
this.setState({ columns: columns });

this._cellPositioner!.reset({
columnCount: columns,
columnWidth: columnWidth,
spacer: gutter
})

if (this._masonry.current)
this._masonry.current.recomputeCellPositions();


return this._cellPositioner!
}
_masonry = React.createRef<Masonry>()

cellRenderer = ({ index, key, parent, style }: any) => {
const props = this.props;
if (!props.items[index])
return <div>404</div>

const item = props.items[index];
let customRender = props.customRender;

const size = this.props.imageSizeResolve(item);
const columnWidth = this.columnWidth()
return (
<CellMeasurer cache={this.cache} index={index} key={key} parent={parent}>
{customRender ? customRender(item, style, columnWidth) :
<div style={style}>
<img
src={item.url}
style={{
width: columnWidth,
height: columnWidth / size.width * size.height
}}
/>
</div>}
</CellMeasurer>
);
}
public render() {
const props = this.props;

this._initCellPositioner();

const columnWidth = this.columnWidth()
let paddingLeft = props.width < columnWidth ? 0 : (props.width - (columnWidth + gutter) * this.state.columns) / 2
if (paddingLeft < 0) {
paddingLeft = 0;
}
return (
<Masonry
style={{
paddingLeft
}}
overscanByPixels={1080}
ref={this._masonry}
autoHeight={false}
cellCount={props.items ? props.items.length : 0}
cellMeasurerCache={this.cache}
cellPositioner={this.cellPositioner(props.width)}
cellRenderer={this.cellRenderer}
height={props.height}
width={props.width}
/>
);
}
};


Anyway to accomplish this?







css reactjs material-ui react-virtualized






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 9:02







tweetypi

















asked Dec 29 '18 at 8:56









tweetypitweetypi

7,05224100206




7,05224100206













  • can you attach rendered DOM part that holds it?

    – mkbctrl
    Dec 29 '18 at 9:00











  • @mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

    – tweetypi
    Dec 29 '18 at 9:02






  • 1





    oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

    – mkbctrl
    Dec 29 '18 at 9:17











  • take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

    – mkbctrl
    Dec 29 '18 at 9:20











  • Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

    – mkbctrl
    Dec 29 '18 at 9:25



















  • can you attach rendered DOM part that holds it?

    – mkbctrl
    Dec 29 '18 at 9:00











  • @mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

    – tweetypi
    Dec 29 '18 at 9:02






  • 1





    oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

    – mkbctrl
    Dec 29 '18 at 9:17











  • take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

    – mkbctrl
    Dec 29 '18 at 9:20











  • Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

    – mkbctrl
    Dec 29 '18 at 9:25

















can you attach rendered DOM part that holds it?

– mkbctrl
Dec 29 '18 at 9:00





can you attach rendered DOM part that holds it?

– mkbctrl
Dec 29 '18 at 9:00













@mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

– tweetypi
Dec 29 '18 at 9:02





@mkbctrl since I'm using react-virtualized the rendering isn't done directly by me, I've attached the virtualized component, cellRenderer is where it's ultimately rendered from...

– tweetypi
Dec 29 '18 at 9:02




1




1





oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

– mkbctrl
Dec 29 '18 at 9:17





oh, pitty. Usually when I have simillar problem with z-index, taking a look at the DOM helps me figure it out. Still, I will try to help, maybe smth will stand out.

– mkbctrl
Dec 29 '18 at 9:17













take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

– mkbctrl
Dec 29 '18 at 9:20





take a look here, maybe that one will aid: stackoverflow.com/questions/20851452/…

– mkbctrl
Dec 29 '18 at 9:20













Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

– mkbctrl
Dec 29 '18 at 9:25





Did you try to set zIndex with the new transform? Just thinking out loud, but if you read this part of attached response: Note that after removing .test's -webkit-transform rule you can, once again, give it its own stacking context by setting a new z-index rule (any value) on .test (again, because it is positioned)! it actually start to make sense

– mkbctrl
Dec 29 '18 at 9:25












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968138%2fsetting-z-index-and-transform%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53968138%2fsetting-z-index-and-transform%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas