import isCover from './isCover' ; import { Layer } from '../types' ; /**
 * 反向覆盖的元素则进行定位处理
 */ const handleDelete = ( data ) => { for ( let i = 0 ; i < data . length ; i ++ ) { const currItemI = data [ i ] ; for ( let j = i ; j < data . length ; j ++ ) { const currItemJ = data [ j ] ; if ( currItemI . structure . zIndex > currItemJ . structure . zIndex && isCover ( currItemI , currItemJ ) ) { if ( currItemI . style ?. background ?. color ?. alpha === 1 ) { currItemJ . isDelete = true ; } } else if ( currItemI . structure . zIndex < currItemJ . structure . zIndex && isCover ( currItemJ , currItemI ) ) { if ( currItemJ . style ?. background ?. color ?. alpha === 1 ) { currItemI . isDelete = true ; } } } } data = data . filter ( ( item ) => ! item . isDelete ) ; for ( let i = 0 ; i < data . length ; i ++ ) { if ( Array . isArray ( data [ i ] . children ) && data [ i ] . children . length > 0 ) { data [ i ] . children = handleDelete ( data [ i ] . children ) ; } } return data ; } ; export default handleDelete ;